0

I'm making a people directory with the A - B - C etc. links, where clicking a letter will take you to the people whose last names begin with that letter. I have a People channel with a last_name field that I can use.

Can anyone recommend a good way to approach this? Thank you.

4

You might use "Low Alphabet"

See the tags from here: http://gotolow.com/addons/low-alphabet/docs/tags

For last_name, just pass parameter orderby="last_name" within {exp:low_alphabet:entries}

0
2

Disclosure: This is probably insane.

That said, here's what I did to "solve" the problem utilizing P&T's Iterate plugin and Stash:

    <ul class="item-list-nav">
{exp:iterate alpha='a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z' parse='inward'}
        <li class="ig-{alpha}"><a href="#ig-{alpha}">{alpha}</a></li>
{/exp:iterate}
    </ul>

{exp:iterate alpha='a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z' parse='inward'}
    <div class="item-list-group" id="ig-{alpha}"><a name="ig-{alpha}"></a>
        <span class="item-list-group-title">{alpha}</span>
        <ul>
    {exp:stash:get_list name='service_list' match='#^(?i){alpha}#' against='item_title'}
            <li><a href="{item_url}">{item_title}</a></li>
    {/exp:stash:get_list}
        </ul>
    </div>
{/exp:iterate}

Insane? Maybe. But does it work? You bet.

2
  • Does this take into account letters that do not have an associated item? For example, will it output "Q" and then an empty list, because I don't have any last names that start with "Q"?
    – Bryan
    Jul 19 '13 at 18:24
  • In my project an empty placeholder div (with the letter) was precisely the desired outcome. There are a few ways that you could avoid the empty lists--using something like {exp:stash:list_count}, for example. Jul 19 '13 at 18:30
1

At first I was thinking of trying the search:field parameter, but instead used a href="#A" links at the top with named anchors with PHP on Output in my channel entries loop:

    <td id="<?
                    $lchar1 = substr("{last_name}", 0, 1);
                    if ($lchar1 != @$lchar2)
                        echo "$lchar1";
                    $lchar2 = $lchar1;
   ?>">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.