3212 Posts in 847 Topics by 809 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 356 Views |
-
Repeating HTML structure for different includes

25 May 2012 at 2:05am Last edited: 25 May 2012 2:29am
hello,
i'm a frontend designer with small programming knowledge and have the following question:
<aside>
..
..
<% if getFeaturedCount %>
<div class="block">
<div class="header">
<h2>Project Featured</h2>
</div>
<div class="content">
<div class="list">
<% control getProjectFeatured %>
<div class="item">
<ul>
<li><a href="$Link">$title</a></li>
<li>$shorttitle</li>
<li>$year</li>
</ul>
</div>
<% end_control %>
</div>
</div>
</div>
<% end_if %>
<% if getLabCount %>
<div class="block">
<div class="header">
<h2>Labs</h2>
</div>
<div class="content">
<div class="list">
<% control getLabList %>
<div class="item">
<ul>
<li><a href="$Link">$name</a></li>
<li>$subtitle</li>
<li>$Logo</li>
</ul>
</div>
<% end_control %>
</div>
</div>
</div>
<% end_if %>
..
..
</aside>i have structures like above (typical sidebar blocks) and as you can see i have to print the output of different models (datatypes) in the always same html structure
<div class="block">
<div class="header">TITLE
</div>
<div class="content">ITEMS
</div>
</div>in smarty for example i would include another template for each block and give parameters with it (TITLE, ITEMS) and
would end with the following:<aside>
...
...
{include myblock.html
title="Project Featured",
items=$getProjectFeatured()}{include myblock.html
title="Labs",
items=$getLabList()}...
...
</aside>how to do this in silverstripe?
thanks and best regards sb
-
Re: Repeating HTML structure for different includes

31 May 2012 at 12:24am
maybe someone can tell me if there is something similar like the smarty example in silverstripe core or if somebody has to programme something special for this ...
-
Re: Repeating HTML structure for different includes

31 May 2012 at 3:38am
Hi sb,
you can do...
<% include TemplateName %>
however when it comes to parameters you don't need them because the included template will be int he same context as the one you are calling it from so it still has the same access to build in page controls or if in a different context (e.g. you used control MyObject).
Here is some more info on the templates... however best to go through the tutorials to get the best idea...
http://doc.silverstripe.org/sapphire/en/topics/templates
http://doc.silverstripe.org/sapphire/en/reference/advanced-templates
| 356 Views | ||
|
Page:
1
|
Go to Top |


