Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » The use of $Layout and subtemplates

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

Page: 1
Go to End
Author Topic: 1240 Views
  • fishe
    Community Member
    42 Posts

    The use of $Layout and subtemplates Link to this post

    Question is whether or not it is possible to use $Layout multiple times in a Page.ss for example. I want to insert "page type specific code" in multiple locations of the Page.ss file - not just the conventional use of $Layout to determine the content area template code by page type but also, for example, parts of the <head> area.

    I realise that using $Layout to do this isn't probably the best why but I don't know another way in SS.

    Perhaps there is a way to use <% include %> statements conditionally based on Page Type? E.g. <if pagetype == blahblah> or something?

    I actually also tried to create a new "Layout-like thing" by creating a directory called "Head", putting a page type specific .ss file in there, and referencing $Head in my root Page.ss file. This didn't seem to work. I guess Layout/$Layout is a hardcoded built in function?

    Thanks for any ideas in advance...

  • Aram
    Community Member
    598 Posts

    Re: The use of $Layout and subtemplates Link to this post

    Hi fishe

    how different do your pages need to be? What exactly do you need to be in your header that you can't do with normal functions (like require, $Metadata etc?

    You can do conditional statements based on page class like this: <% if ClassName = ClassType %>

    That way you could have conditional statements in your include, but that could get a little messy.

    If you elaborate on what exactly you need we may be able to find a better way

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.