Hiding a content block in v5.0
I created a new class that inherits from Telerik.Sitefinity.Modules.GenericContent.Web.UI.ContentBlock. The purpose of this class is to be able to administer on the page editor whether a content block can be should be visible to anonymous users or authenticated users.
public
class
AuthorizedContentBlock : ContentBlock
public
bool
HideFromAnonymousUser
get
;
set
;
public
bool
HideFromAuthenticatedUser
get
;
set
;
protected
override
void
Render(HtmlTextWriter writer)
var authenticated = ...
//custom implementation
if
(HideFromAnonymousUser && !authenticated)
this
.Visible =
false
;
if
(HideFromAuthenticatedUser && authenticated)
this
.Visible =
false
;
base
.Render(writer);
Hello,
Inject the logic in InitializeControls method override InitializeControls and after calling the base method add the logic for hiding the control.
protected
override
void
InitializeControls(GenericContainer container)