Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Only show content on some pages

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: 1137 Views
  • raamklaza
    Avatar
    Community Member
    182 Posts

    Only show content on some pages Link to this post

    Hello,

    i want to add a section for commercial banners on a website.

    I want this banner to be shown on some pages but not all.

    How can i arrange this? Can i do this in the .ss file? Like
    if page != home {
    fkjjfjfdjfgdgf
    }
    endif

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Only show content on some pages Link to this post

    You can use the URLSegment, ClassName, Title, or anyother identifier. I personally always have a HomePage.php page type so I prefer to use classname but your could use urlsegment. Negation is not supported currently by SS so you have to do a bit of a work around

    <!-- based on classname -->

    <% if ClassName = HomePage %><% else %> <!-- DO SOMETHING --> <% end_if %>

    <!-- based on url -->

    <% if URLSegment = home %><% else %> <!-- DO SOMETHING --> <% end_if %>

    For a list of template actions see http://doc.silverstripe.com/doku.php?id=built-in-page-controls

  • raamklaza
    Avatar
    Community Member
    182 Posts

    Re: Only show content on some pages Link to this post

    Thnx willr!

    1137 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.