Previous Page Element

No comments Leave a comment »
The previous post discussed pulling in the "headline" of a previous (parent) page. But what if you want to pull in another element?

OpenText allows you to pull in the following page's element, however it does not provide the same feature for pulling in information from a parent page. Enter render tags.

In this example, my element is named "stf_moreinfo". This is text on the navigation items for each subsection of the website. I am allowing the editors to determine this text field for their section. As they create pages within their section, this field will automatically populate with the text put on their homepage so that they only need to enter the data once.

<%!!Context:CurrentPage.MainLink.OwnerPage.Elements.GetElement(stf_moreinfo).GetHtml()!!>

But then I ran into the problem when editors started creating grandchild pages. The script above goes one layer deep and does not touch the second level. This was solved by doubling up on the elements.

<%!!Context:CurrentPage.MainLink.OwnerPage.MainLink.OwnerPage.Elements.GetElement(stf_moreinfo).GetHtml()!!%>

I limit the number of levels to 4, and to accomadate these levels I have a dirty bit of replicating code that could probably be more elegant given a counter statement embedded in the navigation, but for now this solution gets the element to post whether the template is embedded on level 2 or level 4.

<%!!Context:CurrentPage.MainLink.OwnerPage.Elements.GetElement(stf_moreinfo).GetHtml()!!%>
<%!!Context:CurrentPage.MainLink.OwnerPage.MainLink.OwnerPage.Elements.GetElement(stf_moreinfo).GetHtml()!!%>
<%!!Context:CurrentPage.MainLink.OwnerPage.MainLink.OwnerPage.MainLink.OwnerPage.Elements.GetElement(stf_moreinfo).GetHtml()!!%>

Basically I layered three levels with the GetHtml tag. It says:
"if your parent page has a value for stf_moreinfo then display that info, if not go to next bit of code."
"if above is false then search parent page's parent and display that value"
"if above is false search parent page's parent page's parent element and display that value"
else just skip.

About This Entry

Published on Monday, April 13 2009 at 04:43 PM by Tiffany France in the WebCMS (OpenText Management Server) blog.

Need Help?

If you need immediate assistance, please contact the Help Desk at (804) 828-2227 or submit a ticket online. You can also submit feedback through our Feedback form above or leave a comment on specific blog entries.

Don't Get Phished

Don't be a phishing victim - VCU and other reputable organizations will never use email to request that you reply with your password, social security number or confidential personal information. Learn more about phishing »

No comments below.

There are currently no comments. Be the first to respond.

Add your thoughts