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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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   1800 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