Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » a "require" block in a "if/end_if" block : is it possible

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

Page: 1
Go to End
Author Topic: 1126 Views
  • Myrdhin
    Avatar
    Community Member
    67 Posts

    a "require" block in a "if/end_if" block : is it possible Link to this post

    Hello,

    I try do to that :

    <% if ClassName != HomePage %>
       <% require themedCSS(pageLayout) %>
       <% require themedCSS(pageTypography) %>
    <% end_if %>

    But it doesn't work : the pageLayout and pageTypography CSS files are read when i call a HomePage type. I know it's possible to do in the init() function in the controller classes (other than HomePage_controller) but i would like to do in the template.

    Is it possible ? Perhaps i do a mistake ?
    thanks for your help.

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: a "require" block in a "if/end_if" block : is it possible Link to this post

    I'm not sure if you can even put <% requirements .. %> in if blocks (although i see no reason why not). However, i have never known != to work in the templating language (despite what the recipes / docs / tutorials say) so you have to go:

    <% if ClassName = HomePage %><% else %>
    ....
    <% end_if %>

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: a "require" block in a "if/end_if" block : is it possible Link to this post

    You can put Requirements calls anywhere but they won't respect <% if %> blocks.

  • Myrdhin
    Avatar
    Community Member
    67 Posts
    1126 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.