ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Alphabetical group listing (A-E, F-J etc) and sorting?

May 21, 2009 6:50am

Subscribe [4]
  • #1 / May 21, 2009 6:50am

    LucPestille

    146 posts

    Hi,
    I’m trying to create a 5 column, alphabetically split, list of the artists I’m creating in a weblog, but the logic escapes me. If it were split by A,B,C,D etc, it would be easier (and I’ve seen threads on that), but the logic escapes me on how to do this variant of it;

    I want to split the list into 5 columns, A-E, F-J, K-O, P-U, V-Z, and be able to sort by firstname/surname - has anyone done something similar, or can help me with the logic/php behind it? Is it better to have one {exp:weblog:entries}, and loop in php, or use 5 custom queries?

    Thanks,

    {embed="embeds/above_content" location="artists" opt_page_title="Artists"}
    
            <div id="artists-header">
                <h1>Artists</h1>
                Sort by <a href="http://?sort=firstname" class="list-sort">Firstname</a> or <a href="http://?sort=surname" class="list-sort">Surname</a>
            </div>
    
            <div class="artists">
                <h4>A - E</h4>
    <p>            <ul><br />
                {exp:weblog:entries weblog="artists" disable="categories|member_data|pagination|trackbacks" sort="asc" orderby="artist_firstname" }<br />
                    <li class="clearfix"><br />
                        <a href="#" class="more-info">more</a><br />
                        <a href="http://{url_title_path=artists/artist}" title="{artist_firstname} {artist_surname}" class="artist-listing">{artist_firstname} {artist_surname}</a></p>
    
    <p>                    {reverse_related_entries id="artist" limit="1"}<br />
                        <div class="art"><br />
                            <div class="art-container"><a href="http://{url_title_path=gallery/art}">_                        {exp:imgsizer:size image="{artwork}" width="180" height="110" alt="{title}"}</a><br />
                            </div><br />
                        </div><br />
                        {/reverse_related_entries}</p>
    
    <p>                </li><br />
                {/exp:weblog:entries}<br />
                </ul><br />
            </div></p>
    
    <p>{embed="embeds/below_content"}

  • #2 / May 24, 2009 2:40pm

    Rob Allen

    3114 posts

    I’d first look at this by using categories for the A-Z, the use Dynamic parameters to allow sorting of entries.

  • #3 / May 24, 2009 4:27pm

    LucPestille

    146 posts

    I don’t particularly want to use categories for something that’s already filled in - it seems odd to me, and will be equally odd to the client “You meant I have to Fill in ‘Adam’,‘Davison’ AND tick ‘A’ AND ‘D’?” Surely there’s a better way, even if it involves some php?

  • #4 / May 24, 2009 6:27pm

    Rob Allen

    3114 posts

    If you don’t want to add new data to your entries then you’d probably need some custom scripting as you suggest.

    There are other ways to do this but they it does involve creating a new custom fields and adding data.

    Sometimes to add functionality you have to bite the bullet 😊

  • #5 / May 24, 2009 7:48pm

    AJP

    311 posts

    Look around the forums for the a-z plugin. But depending on what you’re looking for, you might have to custom code a plugin for it too.

  • #6 / May 25, 2009 5:59am

    e-man

    1816 posts

    If you want sortable data without page reloads it might be worth it to go with tables and then use something like Tablesorter for jQuery: http://tablesorter.com/docs/

  • #7 / May 25, 2009 6:45am

    LucPestille

    146 posts

    I can live with the page reload for sorting - it’s just 2 options for sorting - it’s getting the data in the right structures first that’s the problem!

  • #8 / May 25, 2009 7:10am

    Rob Allen

    3114 posts

    For filtering and sorting entries, Dynamic Parameters might be useful

  • #9 / May 27, 2009 6:31am

    LucPestille

    146 posts

    FYI - I solved it by adding categories for firstname/surname initials, and opting people in to their relevant categories. It’s a long winded way of doing it, but it does work as I wanted it to. Last thing I need is a radio button replacement for the category selection, so people can’t be put in 2 surname categories by mistake - does something like that exist?

    {embed="embeds/above_content" location="artists" opt_page_title="Artists"}
    
            <div id="artists-header">
                <h1>Artists</h1>
                Sort by <a href="/artists/firstname" class="list-sort">Firstname</a> or <a href="/artists/surname" class="list-sort">Surname</a>
            </div>
    
    <?php
    //get sort order from querystring
    global $IN;
    
    $sort_order = "";
    $sort_asc_desc = "";
    
    if ( sizeof( $IN->SEGS ) >1 ){
    $sort_order = $IN->SEGS[2];
    }
    
    
    //set defaults (same as firstname)
    $orderby = "artist_firstname"; 
    $categories_ae = "25|26|27|28|29";
    $categories_fj = "30|31|32|33|34";
    $categories_ko = "35|36|37|38|39";
    $categories_pu = "40|41|42|43|44";
    $categories_vz = "45|46|47|48|49|50";
    $sort_asc_desc = "asc";
    
    // if we're ordering by firstname, set orderby and categories for columns
    if ( $sort_order == "firstname" ){ 
        $orderby = "artist_firstname"; 
        $sort_asc_desc = "asc";
        $categories_ae = "25|26|27|28|29";
        $categories_fj = "30|31|32|33|34";
        $categories_ko = "35|36|37|38|39";
        $categories_pu = "40|41|42|43|44";
        $categories_vz = "45|46|47|48|49|50";
    }
    
    // if we're ordering by surname, set orderby and categories for columns
    if ( $sort_order == "surname" ){ 
        $orderby = "artist_surtname"; 
        $sort_asc_desc = "desc";
        $categories_ae = "51|52|53|54|55";
        $categories_fj = "56|57|58|59|60";
        $categories_ko = "61|62|63|64|65";
        $categories_pu = "66|67|68|69|70";
        $categories_vz = "71|72|73|74|75|76";
    } ?>
    
            <div class="artists">
                <h4>A - E</h4>
    <p>            <ul><br />
                {exp:weblog:entries weblog="artists" category="<?php echo $categories_ae; ?>" disable="member_data|pagination|trackbacks" sort="<?php echo $sort_asc_desc; ?>" orderby="<?php echo $orderby; ?>" }<br />
                    <li class="clearfix"><br />
                        <a href="#" class="more-info">more</a><br />
                        <a href="http://{url_title_path=artists/artist}" title="{artist_firstname} {artist_surname}" class="artist-listing">{artist_firstname} {artist_surname}</a></p>
    
    <p>                    {reverse_related_entries id="artist" limit="1"}<br />
                        <div class="art"><br />
                            <div class="art-container"><a href="http://{url_title_path=gallery/art}">_                        {exp:imgsizer:size image="{artwork}" width="180" height="110" alt="{title}"}</a><br />
                            </div><br />
                        </div><br />
                        {/reverse_related_entries}</p>
    
    <p>                </li><br />
                {/exp:weblog:entries}<br />
                </ul><br />
            </div></p>
    
    <p>        <div class="artists"></p><h4>X - X</h4><p></div><br />
            <div class="artists"></p><h4>X - X</h4><p></div><br />
            <div class="artists"></p><h4>X - X</h4><p></div><br />
            <div class="artists"></p><h4>X - X</h4><p></div></p>
    
    <p>{embed="embeds/below_content"}

  • #10 / May 27, 2009 6:44am

    e-man

    1816 posts

    Nice solution. Fieldframe has a radio group option but alas not for categories:
    http://brandon-kelly.com/apps/fieldframe

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases