Portal Engine
Version 3.x > Portal Engine > How to get parent node information? View modes: 
User avatar
Member
Member
gnum - 3/27/2008 12:29:49 PM
   
How to get parent node information?
I am using <%= CMS.CMSHelper.CMSContext.CurrentPageInfo.DocumentName.ToString() %> in template to get document name. Now i need to get parent-level document name. <%= CMS.CMSHelper.CMSContext.CurrentPageInfo.ParentPageInfo.DocumentName.ToString() %> is causing error. How i can get this value?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/27/2008 3:02:19 PM
   
RE:How to get parent node information?
Hi,

Thank you for your message.

Could you please try to use something like this:

TreeNode tn = SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentDocument.NodeParentID);

if (tn <> null)
{
//you got the parent ID and you can use it to get more info
}

I hope this will cover your needs.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
michael.jenkinson-getstarted.com - 2/22/2010 7:16:54 PM
   
RE:How to get parent node information?
Have there been more efficient ways created since this post to retrieve a document name?

SelectSingleNode has a lot of overhead in loading the CMS Tree view, just to get a single field.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 2/23/2010 7:45:23 AM
   
RE:How to get parent node information?
Hi,

You can compose a custom SQL query which will return just the document name from the database and in WHERE condition you will use the parent node ID and pass it to the query using ExecuteQuery method.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
cortezstephen-gmail - 8/9/2010 11:58:22 AM
   
RE:How to get parent node information?
Seeking Senior Leadership for a SAP Practice Manager with at least 8-10 years of experience in business development and delivery management of SAP solutions to manage. http://www.column5.com/epm-implementation.php