Jump to:

23023 Posts in 11882 Topics by 2830 members

General Questions

SilverStripe Forums » General Questions » I need the children of a urlsegment to inherit a theme

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

Page: 1
Go to End
Author Topic: 1346 Views
  • Todd
    Avatar
    31 Posts

    I need the children of a urlsegment to inherit a theme Link to this post

    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

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: I need the children of a urlsegment to inherit a theme Link to this post

    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

    1346 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.