Forum
Help with perch:if in template
Having a hard time figuring out the best way to create an user listing and have my template create the index letter (A,B, C, etc) based on last name and have close the <ul> properly depending on if there is a single or multiple users with a certain last name.
I am hoping not to have to create a custom content area for each letter and then filtering.
A
- Johnny Appleseed
B
- Billy Bob
- James Brooks
etc...
<perch:before>
<div class="alumni-list">
</perch:before>
<perch:if different="lastname">
<h5 class="alumni">
<perch:content id="lastname" type="text" chars="1" />
</h5>
<ul class="alumni-letter">
<li>
<a href="/aboutus/alumni-detail.php?item=<perch:content id="slug" />
">
<strong>
<perch:content id="firstname" />
<span>
<perch:content id="lastname" />
</span>
</strong>
</a>
<span class="alumni-year">
(
<perch:content id="alumni-year" type="text" help="format: 1984-1986" label="Years Attended" order="5" />
)
</span>
</li>
<perch:else />
<li>
<a href="/aboutus/alumni-detail.php?item=<perch:content id="slug" />
">
<strong>
<perch:content id="firstname" />
<span>
<perch:content id="lastname" />
</span>
</strong>
</a>
<span class="alumni-year">
(
<perch:content id="alumni-year" type="text" help="format: 1984-1986" label="Years Attended" order="5" />
)
</span>
</li>
</ul>
</perch:if>
<perch:after>
Try:
Same issue I was having before. I can't seem to figure out the closing ul tag. I've tried all kinds of things and I either get a closing </ul> after each list item or I get none, or I get it to work with multiple <li> but then it doesn't work with single <li>. Below is my template, it's works aside from closing after each <li>. I've tried putting the </ul> in another "if" condition and in the "after" but can't make it work. Any ideas?
<perch:if different="lastname" format="C:1" case="insensitive"> <h5 class="alumni"><perch:content id="lastname" type="text" chars="1" /></h5> <ul class="alumni-letter"> </perch:if>
Close the
</ul>
at the top of the loop if:Makes perfect sense. I wasn't aware I could use a "Special ID Value" in a perch:if. Now, I see it mentioned on "Tag attribute id" page that you can use in a perch:if, but that information wasn't a option or mentioned on the "Conditionals/if" document.
As always, thank you for your help.