3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1626 Views |
-
<% control %> to list only certain type of sub pages

9 April 2010 at 3:07am Last edited: 9 April 2010 3:36am
First let me say that I'm new to SilverStripe - so there is probably a really simple answer to this that I just can't quite find.
Imagine I have a holder: AnimalHolder
Each AnimalHolder can hold multiple pages of types: CatPage or DogPage
What I want to achieve is to have two separate lists of Cats and Dogs in my AnimalHolder.ss.
I've tried similar to:
<ul id="cats">
<% if ClassName = CatPage %>
<% control Children %>
<li>Cat: $Title</li>
<% end_control %>
<% end_if %>
</ul><ul id="dogs">
<% if ClassName = DogPage %>
<% control Children %>
<li>Dog: $Title</li>
<% end_control %>
<% end_if %>
</ul>however, this does not work.
Any ideas?
-
Re: <% control %> to list only certain type of sub pages

9 April 2010 at 3:24am Last edited: 9 April 2010 3:36am
Ok .. I just figured it out myself. I need to control the Children first, then check ClassName ...
For posterity and the sake of others that may be similarly struggling, the following worked for me:
<ul id="cats">
<% if Children %>
<% control Children %>
<% if ClassName = CatPage %>
<li>$Title</li>
<% end_if %>
<% end_control %>
<% end_if %>
</ul><ul id="dogs">
<% if Children %>
<% control Children %>
<% if ClassName = DogPage %>
<li>$Title</li>
<% end_if %>
<% end_control %>
<% end_if %>
</ul> -
Re: <% control %> to list only certain type of sub pages

21 July 2010 at 3:57pm
Sweet! Thanks for posting the answer!
| 1626 Views | ||
|
Page:
1
|
Go to Top |


