Hello,
I'm doing a one-page site in silverstripe and i have created some templates that will represent my different site parts.
I first tried to loop by using 'include' so :
<% if SlugItems %>
<% loop SlugItems %>
<% include $slug %>
<% end_loop %>
<% end_if %>
But from what i found on forums, it's not the way to do it and i got an error with loop tag missing...So i tried to create a function
public function IncludeTemplate($template) {
return $this->renderWith($template);
}
And
<% if SlugItems %>
<% loop SlugItems %>
<% IncludeTemplate($Slug) %>
<% end_loop %>
<% end_if %>
Big surprise...It's the same, cause i read that both include and renderWith do the same job. Well, i don't really know a good solution and i'd like to implement something more elaborate than including some template if my template name is like X, eg.
<% if $ClassName = 'SomeClass' %>
<% include SomeClass %>
<% else_if $ClassName = 'SomeOtherClass' %>
<% include SomeOtherClass %>
<% else %>
<% include DefaultClass %>
<% end_if %>
If you know a good solution, please write it here! That would make my day :D.
Thanks, Thomas