Jump to:

23477 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » How to have a page uses one a.ss instead of b.ss?

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: 704 Views
  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    How to have a page uses one a.ss instead of b.ss? Link to this post

    I have a file named page.ss that resides at root level of templates/ folder. As image below.

    All of my pages use that page.ss file that contains html tags to form the structure.

    Problem is that i need to add an additional <div> tag into only ONE of the pages.

    So i dupped Page.ss to PageAccueil.ss, and added the <div> tag as needed. FIne, but now ALL of my pages shows that <div>, which i dont want, only one of those page.

    QUESTION:

    How do i LINK a particular page to a particular .ss file?????

    Thanks!

  • Devlin
    Avatar
    Community Member
    215 Posts

    Re: How to have a page uses one a.ss instead of b.ss? Link to this post

    Well, first you should read the tutorial.

    The not-so-nice approach is to simply check the page name in the template:
    <% if URLSegment = whateverpageurl %>
    <div>
    $Content
    $Form
    </div>
    <% else %>
    $Content
    $Form
    <% end_if %>

    The better approach is like it's described in the tutorial:
    - Create a new page type
    - Rebuild Database with /dev/build/?flush
    - Reload the CMS and change the page type of this particular page
    - Replace '$Content $Form' to '$Layout' in Page.ss
    - Make a new Page.ss in the Layout folder
    - Add '$Content $Form' into Layout/Page.ss
    - Make a new [whateverclassnameyouvechosen].ss in the Layout folder
    - Add '<div>$Content $Form</div>' into Layout/[whateverclassnameyouvechosen].ss
    - Reload the webpage with ?flush in the end of the URL.

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