Unsolved mystery: How to alphabetically list multi-author posts by author?
Posted: 02 July 2008 10:25 AM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  28
Joined  01-21-2007

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.

Profile
 
 
Posted: 07 July 2008 03:28 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  201
Joined  12-16-2006

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

 Signature 

420 Design - web design + development | EE Pro Network Member

Profile
 
 
Posted: 08 July 2008 11:52 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  28
Joined  01-21-2007

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="{url_title_path=">{author_A_firstname} {author_A_lastname}</a></li>
       
{/if}
       {if author_B_firstname}
               
<li><a href="{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!

Profile
 
 
Posted: 08 July 2008 12:34 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  201
Joined  12-16-2006

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!

 Signature 

420 Design - web design + development | EE Pro Network Member

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64935 Total Logged-in Users: 52
Total Topics: 81900 Total Anonymous Users: 27
Total Replies: 440276 Total Guests: 269
Total Posts: 522176    
Members ( View Memberlist )