1

I have a simple news site and on a single entry page where a news item is located I would like to list 3 or 4 other entries by the same author in the sidebar sorted by date.

I have one channel entries tag for the article text and another with the same channel but with an author_id parameter.

There are two problems I'm having, one is getting the author id from the url (I do not want to add another url segment just for this) and the second is making sure that it doesn't list the same entry that's currently being displayed on the page.

I would post my current code but it's all very standard stuff

1 Answer 1

2

Assuming you're not using stash, you can simply use an embed within your main channel entries tag and pass the embed the author_id of the current author and the entry_id of the article being displayed:

{embed="sidebar/authorlist" author_id="{author_id}" entry_id="{entry_id}"}

and in your embed:

{exp:channel:entries channel="..." dynamic="no" author_id="{embed:author_id}" entry_id="NOT {embed:entry_id}"}

Because it's a single entry page (limit="1") your embed will only be included once - but it means that your sidebar area in your template needs to be within the {exp:channel:entries} loop

2
  • aaah ok I didn't know it was possible to add a channel entries tag within another entries tag...I guess it doesn't work if it's not in an embed though...thanks a bunch, this will help me out for sure...I just started using stash too but I'll check out the documentation first before asking any other questions, cheers! :)
    – Dovla
    Commented Jan 16, 2014 at 11:35
  • any chance you could tell me how this same thing could be done with stash?
    – Dovla
    Commented Jan 29, 2014 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.