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.

Sorting Blog Entires By Author

July 22, 2011 6:52pm

Subscribe [3]
  • #1 / Jul 22, 2011 6:52pm

    ThePigeonHold

    8 posts

    Hey all,

    This may be something rather simple but I can’t seem to find a solution. I am building a blog for one of my clients and they would like the ability to sort all entries on the blog by author. So, essentially, users would be able to click on the Author’s name in the article info and be sent to a page listing only articles by that author.

    I did some research and saw that you can add an {author_id="1"} variable in the EE tag that can limit which author’s entries show up on the page. However, the only way I can see that working is if I build a separate page for each author and have their name link to that page. But that doesn’t seem like something that will be much fun to update every time they add a new author to the site.

    It seems there must be a simple way of doing something like this but I must be just missing it in my searches.

    Any help would be greatly appreciated.

    Cheers,

    TPH.

  • #2 / Jul 23, 2011 11:27am

    Mark Bowen

    12637 posts

    Well you have access to the {author_id} variable from within an entry so you should be able to do something like this :

    <a href="http://{path=%27posts/posts_by_author%27}/{author_id}" title="View authors posts">View all posts by {author}</a>

    That should then hopefully take you to a page that looks something like this :

    http://www.example.com/posts/posts_by_author/x

    Where x should be showing the author ID instead.

    You should then in the posts_by_author template be able to do this now :

    {exp:channel:entries
        channel="default_site"
        author_id="{segment_3}"
        dynamic="no"
        sort="asc"
        disable="member_data|pagination|categories"}
    
    {title}
    
    {/exp:channel:entries}

    That should then hopefully take the author_id which is currently in {segment_3} of the URL and use it within the Channel Entries Tag to whittle down the entries to just those by that author.

    There is also a username=”“ Channel Entries parameter which you could use if you wanted the authors name in the URL instead.

    You would need to change the link above to utilise the {username} variable instead of the {author_id} variable though.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #3 / Jul 24, 2011 4:35pm

    ThePigeonHold

    8 posts

    Beautiful! Works like a charm! Thanks for the suggestion.

  • #4 / Jul 25, 2011 2:28am

    John Henry Donovan

    12339 posts

    Thanks Mark. Feel free TPH, to start a new thread if you have any more questions

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

ExpressionEngine News!

#eecms, #events, #releases