Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

sub-sub-templates / controllers for granulated front page layout


Reply


2 Posts   1462 Views

Avatar
stadolf

Community Member, 1 Post

5 August 2009 at 2:00am

Edited: 05/08/2009 2:01am

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">
         <h2>$Title</h2>
         <div class="content">
            <% if ClassName = HomePageArticleContainer %>
               <ul>
                  <% control AllChildren %>
                     <li onhover="...">$Title</li>
                  <% end_control %>
               </ul>

               <% control AllChildren %>
                  $RenderForFrontPage
               <% end_control %>

            <% else_if ClassName = HomePageArticle %>
               Article
            <% end_if %>
         </div>
      </div>
   <% end_control %>
</div>

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

Avatar
joshy

Community Member, 57 Posts

5 August 2009 at 11:38pm

Hiya,

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:
http://doc.silverstripe.org/doku.php?id=tutorial:5-dataobject-relationship-management

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

Josh