Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » sub-sub-templates / controllers for granulated front page layout

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

Page: 1
Go to End
Author Topic: 1395 Views
  • stadolf
    Community Member
    1 Post

    sub-sub-templates / controllers for granulated front page layout Link to this post

    Hi. I'm totally new to SS and after consulting the tutorials and trying for some hours I'm simply stuck.
    Here's the scenario:

    The homepage shows several areas that can be dynamically packed with content. The boxes should be JS-tabbed, so one box can contain several teasers. My approach:

    ArticleHolder - the main page
    ArticleContainer - a container, resembling one box that can hold several Articles
    Article - one item within a Container

    An ArticleHolder can hold ArticleContainers as well as Articles (eg for showing a standalone video box / teaser)

    Now I'm getting confused with the templating mechanism. Here's my Layout/ArticleHolder.ss

    <div class="typography">
       <% control AllChildren %>
          <div class="HomePageArticle">
             <div class="content">
                <% if ClassName = HomePageArticleContainer %>
                      <% control AllChildren %>
                         <li onhover="...">$Title</li>
                      <% end_control %>

                   <% control AllChildren %>
                   <% end_control %>

                <% else_if ClassName = HomePageArticle %>
                <% end_if %>
       <% end_control %>

    See that control AllChildren within? How do I tell SS to use a specific template (Article.ss) to render the bunch of children? I would use that template to render the standalone articles, too (see else_if). If it's done within the controller (->renderWith("Article.ss")), how do I name/call the controller's method from the base template (seen above) ?

    Appreciate your help very much and kind regards to Wellington, hope you guys have a great time there !

    Thanks, Stefan

  • joshy
    Community Member
    57 Posts

    Re: sub-sub-templates / controllers for granulated front page layout Link to this post


    Welcome to the silverstripe forums .

    I think you're going about this the wrong way. Rather than sub-sub-templating I suggest you assign each page into a category (ie Tab1, Tab2, Tab3). You'll then need to add a controller method to loop through these in the way you want.

    I am not sure I understand your problem in entirety so sorry if I am branching off from what you need.

    There are two ways to do this - the 'proper' way which allows for expansion or the quick and dirty way.

    The quick/dirty way is to add a dropdown to the Article[Page] which has options of 'Tab1', 'Tab2', 'Tab3' etc and then control them with a custom method. The proper way is to create a DataObject called 'Tabs' which you can then access/overload/do whatever you want with. The way you access them from the template is fairly similar.

    Proper way:

    I will try come back to this post and give you code examples. However, I have, for now, run out of time - sorry!


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.