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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

I need the children of a urlsegment to inherit a theme


Go to End


2 Posts   2114 Views

Avatar
Todd

31 Posts

22 December 2009 at 8:42pm

Hi,

The code below works for the one page:

if(($this->URLSegment) == ''SomePage") {
SSViewer::set_theme('newTheme');
}else{
SSViewer::set_theme('default');
}

How can I get 'newTheme' to be inherited by the children of 'SomePage'?

Thanks,

Todd

Avatar
ChrisBryer

Community Member, 95 Posts

23 December 2009 at 12:45pm

this works for the next level down:

if($this->URLSegment == ''SomePage" || $this->Parent()->URLSegment == "SomePage") {
         SSViewer::set_theme('newTheme');
      }else{   
         SSViewer::set_theme('default');
      }       

beyond that, you should set up a recursive function to recurse through the parent chain, looking for 'somepage' as the url until you hit a Page ID of 0.

-Chris