I ve been reading some event examples and i ve added an example of some code below, my question is (being a total newbee i.e. day 1) what do I save this file as and where do I save it to make use of
Sorry such a daft question but very new to this and keen to learn
Gibbo
usingSystem; using umbraco.BusinessLogic; using umbraco.cms.presentation.Trees;
namespaceOnlyForAdmins { /// <summary> /// Makes a document invisible for writers /// </summary> publicclassMenuIsNotForWriters:ApplicationBase { /// <summary> /// Wire up the event handler /// </summary> publicMenuIsNotForWriters() { BaseContentTree.AfterNodeRender+=newBaseTree.AfterNodeRenderEventHandler(BaseContentTree_AfterNodeRender); }
/// <summary> /// Removes node from menu tree if page is protected and the user is a writer /// </summary> voidBaseContentTree_AfterNodeRender(refXmlTree sender,refXmlTreeNode node,EventArgs e) { //check if page is protecetd and the usertype is writer if(node.IsProtected.GetValueOrDefault(false)&& umbraco.helper.GetCurrentUmbracoUser().UserType.Alias=="writer") { //Writers cannot see protected pages sender.Remove(node); } } } }
The simplest way to add code to the site is to place it in a .cs file inside the "/App_Code" folder (you can name the file as you like but keep its extension ".cs"). Another option is to compile the file into a separate assembly and put it into the "/bin" folder.
However, it seems that what you want to achieve is doable in much simpler way without coding by setting proper permissions to the content node (right click -> "Permissions").
Help please
All
I ve been reading some event examples and i ve added an example of some code below, my question is (being a total newbee i.e. day 1) what do I save this file as and where do I save it to make use of
Sorry such a daft question but very new to this and keen to learn
Gibbo
The simplest way to add code to the site is to place it in a .cs file inside the "/App_Code" folder (you can name the file as you like but keep its extension ".cs"). Another option is to compile the file into a separate assembly and put it into the "/bin" folder.
However, it seems that what you want to achieve is doable in much simpler way without coding by setting proper permissions to the content node (right click -> "Permissions").
Rodion is right. You probably don't need events to do this. If you still want more info about events you can find it here:
http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events
http://www.richardsoeteman.net/2009/02/22/UmbracoV4EventsDemo.aspx
Jeroen
is working on a reply...