Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[solved] Find out whether a page has a certain page / grandparent.


Go to End


2 Posts   1143 Views

Avatar
njprrogers

Community Member, 23 Posts

7 April 2011 at 4:30am

Hi,

I'm looking to show a different header and footer in my templates depending on whether the current page has a certain ancestor.

So if the url has

www.mysite.com/us/mycategory/mypage perform one action

else
if the url has

www.mysite.com/nz/mycategory/mysubcategory/mypage perform another action.

I want to show one header and footer for us and another for nz. The page could be a variable number of levels down the heirarchy. Is there anything in SilverStripe to do this?

Thanks,

Nick

Avatar
njprrogers

Community Member, 23 Posts

7 April 2011 at 4:56am

Solved:

<% if InSection(nz) %>
<p>God Bless NZ!</p>
<% end_if %>