We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Show entries by one author, then split into categories

Development and Programming

onedogmedia's avatar
onedogmedia
31 posts
13 years ago
onedogmedia's avatar onedogmedia

I have many authors, and each of them create entries that are categorized into a set of common categories, such as red, green and blue. I want to show all the entries by a single author, then offer links to each category, that when clicked show only that author’s entries in the selected category.

So like:
Bob Smith: Red (show bob’s red entries) Green (show bob’s green entries) Blue (show bob’s blue entries)

So I show all the author’s entries using this:

{exp:channel:entries channel="art" author_id="{segment_3}" dynamic="no" limit="20" paginate="both"}

Which gives me a URL like: mysite.com/art/artist/26. Where 26 is the author_id. I found that if I did not use dynamic=”no”, it would display nothing. So just showing the entries from this author works.

Then I wanted to show all that author’s items in a particular category using these links:

{exp:channel:categories channel="art" category_group="3" style="linear"}
      <li><a href="http://{path=art/artist/{segment_3}}">{category_name}</a></li>
{/exp:channel:categories}

So the categories display correctly, and the links to them look like this: mysite.com/art/artist/26/C24.

But I’m having trouble limiting them by BOTH author and category. Having the “C24” or whatever category ID at the end of the URL does nothing - it just still shows all the entries by that author from any category. Obviously, this needs dynamic=”yes” in order to work, so it seems like I can’t have my cake and eat it too.

Am I going about it backwards? Should I be somehow designating the category first, setting dynamic=”yes” and then finding another way to limit by the author_id that does not require dynamic=”no”?

Or do I need some kind of SQL query to pull the author_id ?

Would love some help if anyone has advice. THanks!

       
onedogmedia's avatar
onedogmedia
31 posts
13 years ago
onedogmedia's avatar onedogmedia

I figured this out for anyone who has this same issue.

In the original template, I used an embed and sent over the author id and the current category like so:

{embed="art/results" author_id="{segment_3}" category="{exp:channel:category_heading}{category_id}{/exp:channel:category_heading}"}

Then in the embedded template, I used dynamic=”no” and the variables like this:

{exp:channel:entries channel="art" author_id="{embed:author_id}" category="{embed:category}" dynamic="no" limit="20" paginate="both"}

So the category links look like mysite.com/art/artist/26/C24 where 26 is the author id and C24 is the category. So the embedded template is not using the C24 dynamically, but it knows the category id because I sent it over from the embedding.

When it is the author’s main page, and thus there is no category id to send to the embed, it still seems to work (i guess category=”” just returns all the results).

I just needed to think a little more! But hopefully this will help someone.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.