17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1061 Views |
-
conditional html in templates

5 September 2008 at 9:49am
In my sample example I have a collection of members who are sorted by industry ( a text field) What I want to do is have a conditional header that is displayed when the industry group changes.
This is an outline of what I want to do.
<div id="MemberList">
<% control MemberList %>
<% if $lastindustry <> $Industry %>
<h2>$Industry</h2>
$lastindustry = $Industry
<% end_if %>
<p>$Title - $CompanyName</p>
<% end_control %>
</div>How best to achieve this?
-
Re: conditional html in templates

5 September 2008 at 3:52pm
the template parser is pretty basic in what you can do, eg you cant assign variables and change $lastIndustry inside the template.
What you would need to do is change your datamodel a bit for the template so you have a DataObjectSet of Industries. Then each industry has a DataObjectSet of Members so in the template you would do
<% control Industries %>
<h2>$Title</h2>
<% control IndustryMembers %>
$Title - $CompanyName
<% end_control %>
<% end_control %>And so your PHP method Industries() would need to make a DataObjectSet of all the Industries then for each Industry generate a list of members for it
| 1061 Views | ||
|
Page:
1
|
Go to Top |


