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.

General Questions /

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

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

I need the children of a urlsegment to inherit a theme


Reply


2 Posts   1449 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