我需要爲umbraco成員(來自最終成員)存儲密碼重置令牌。現在我得到的解決方案是創建一個屬性並使用它。但問題是這個標記應該隱藏在每個人面前。是否有任何干淨的方法來隱藏屬性(不添加對包的依賴)?使Umbraco屬性隱藏
到目前爲止approach我發現這個樣子的,但是我正在尋找更簡單的方法,使財產隱藏:
public class ApplicationHandler : ApplicationEventHandler
{
public ApplicationHandler()
{
ContentControl.AfterContentControlLoad = new ContentControl.AfterContentControlLoadEventHandler(ContentControl_AfterContentControlLoad);
}
private void ContentControl_AfterContentControlLoad(ContentControl contentControl, ContentControlLoadEventArgs e)
{
int docId = 0;
int.TryParse(HttpContext.Current.Request["id"], out docId);
IContent content = ApplicationContext.Current.Services.ContentService.GetById(docId);
Control ctl = umbraco.presentation.LiveEditing.Utility.FindControl<Control>(delegate(Control c)
{
return c.ClientID.EndsWith("propertyAliasToHide");
}, contentControl.Page);
HideProperty(ctl);
}
private void HideProperty(Control control)
{
if (control != null)
{
Control parent = control.Parent;
if (parent != null)
{
if (parent.Parent != null)
{
if (parent.Parent.Parent != null)
{
parent.Parent.Parent.Visible = false;
}
}
}
}
}
}