ASPX templates
Version 3.x > ASPX templates > How to get Top Level Page Name from Sub Page View modes: 
User avatar
Member
Member
beattie.w-gmail - 11/4/2008 10:00:06 PM
   
How to get Top Level Page Name from Sub Page
Is there a way to retrieve the Top Level Document name from a Child Document

For instance I have a navigation e.g.

Products
Product 1
Product 2

On Product1 I want to be able to get the name of it's parent document "Products".

For instance my <h1> element would be Products and my <h2> would be Product1

I can get the current documentName using <%=this.DocumentBase.CurrentPage.DocumentName %>

but not the parent.


Also I want to have a single image for each of the Top Level Sections in my site.
i.e. Products, Product1, Product2 would each share the same image but on another section for instance About Us would have a different image. Is there way to do this and also have it as an EditableRegion without have to create a new template for each section???




User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 11/5/2008 9:20:21 AM
   
RE:How to get Top Level Page Name from Sub Page
Hello,

You will have to insert some custome code, to get the parent name.
You will have to access the parent node and after that get the name of the given node.
You can get the parent node with the following snippet:
CMS.TreeEngine.TreeNode node = CMS.CMSHelper.TreeHelper.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentDocument.NodeParentID);

You can access the parent name as follows:
node.DocumentName.ToString();

You can also implement a custom macro. You can find a short tutorial in our developer's guide at http://devnet.kentico.com/docs/devguide/appendix_a___macro_expressions.htm.

For your second requirement you can use a repeater and change the visual inheritance of a page in "<selected page> -> properties -> template -> select inherited levels"

I hope this helps.

Best Regards,
Boris Pocatko