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.

Unsolved mystery: How to alphabetically list multi-author posts by author?

July 02, 2008 1:25pm

Subscribe [4]
  • #1 / Jul 02, 2008 1:25pm

    sahadeva

    14 posts

    I have a weblog setup where each post has two authors and each author is represented by two custom fields (4 fields total: first_name_A, last_name_A, first_name_B, last_name_B). I’d like to be able to make a list of all the authors who have contributed in my archives page sorted alphabetically by last name, each author name being linked to the post(s) he or she has authored. It should look something like this, a simple list (which is harder to get then it first seems):

    David Apple
    July Child
    Sarah Connor
    Emily Kane
    Erin Song
    John Zerb

    In cases where an author has contributed multiple posts (i.e. when the first and last name of an author show up twice in the database) I’d like to show the dates of those posts and use those to link to the posts, rather than the author name. E.g. if July Child had two posts the list would look like this:

    David Apple
    July Child
      - July 3
      - July 9
    Sarah Connor
    Emily Kane

    I can’t get regular weblog tags to cut it because it will sort entries on a post-by-post basis, not authors (custom fields) on an author-by-author basis, so it can’t get the whole list alphabatized correctly. Ordering a weblog tag by author last name shows a list like this:

    John Zerb [author A post 1]
    David Apple [author B post 1]
    Sarah Connor [author A post 2]
    Emily Kane [author B post 2]
    Erin Song [author A post 3]
    July Child [author B post 3]

    Any clues on how to set up a custom query to work this would be greatly, truly appreciated.

  • #2 / Jul 07, 2008 6:28pm

    Angie Herrera

    365 posts

    Seems like conditionals would be the way to go: http://expressionengine.com/docs/modules/weblog/conditional_variables.html

  • #3 / Jul 08, 2008 2:52pm

    sahadeva

    14 posts

    Here’s the code I tried, using conditionals:

    <div>
            <ul>
    {exp:weblog:entries weblog="{my_weblog}"  orderby="author_A_lastname&author;_B_lastname" sort="asc"}
           {if author_A_firstname}
                   <li><a href="http://{url_title_path=">{author_A_firstname} {author_A_lastname}</a></li>
           {/if}
           {if author_B_firstname}
                   <li><a href="http://{url_title_path=">{author_B_firstname} {author_B_lastname}</a></li>
           {/if}
    {/exp:weblog:entries}
            </ul>
    </div>

    That output doesn’t sort correctly. It’s sorting entries, not the custom fields, as Robin from EE said. I get the impression it’s going to require a custom query—any idea on how that would go? I’ve tried a few things but I’m a custom query novice.

    Thanks!

  • #4 / Jul 08, 2008 3:34pm

    Angie Herrera

    365 posts

    Hm, yeah I see. Custom query would seem to be the way to go but that’s definitely not my strong suit. Sorry I couldn’t be of more help!

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

ExpressionEngine News!

#eecms, #events, #releases