I'm trying to display a list of links dynamically based on the current entry that is being displayed. with code along the lines of this:

{exp:channel:entries channel='tour' disable="category_fields|member_data|pagination" dynamic="no" show_expired="no"}
    {if tour_name=="tour_name"}
        <h4 class="sub"><a href="{site_url}tours/{url_title}">{tour_date_start format="%j %F"} &ndash; {tour_date_end format="%j %F %Y"}</a></h4>

I know that the code above won't work, but thought it illustrated what I was trying to achieve. Basically I have a series of tours and some of them have the same name. I want to display links to these ones with the same name, when viewing one of those tours. I know this would be best to use either categories or a playa field, but aren't able to go this route because some of the data is pulled in from an external database. I tried to use stash to set the current tour_name and then get it within the if conditional, but this wouldn't work either.

I wonder if it would be possible using the query module? Or another plugin? Maybe it's not possible at all?

If anyone can offer any help, I'd appreciate it. Thanks.


You can always pass the data to an embed and search for entries again:

{exp:channel:entries channel='tour' [...] }
    {if tour_name}
        {embed="pages/.related_tours" name="{tour_name}" current_entry="{entry_id}"}    

On you embed, you can look for entries using the query module, sure, but the channel module is easier:

{exp:channel:entries channel='tour' search:tour_name="{embed:name}" entry_id="not {embed:current_entry}" [...]}
  • That's great and works a treat thanks! Would you know a way of not displaying the current entry in that list? – Erbert Jul 24 '14 at 14:58
  • @ErbertCoote, sure! I updated my answer to show how to do that. – Sobral Jul 24 '14 at 15:07
  • Thanks Robson, that's perfect. Really appreciate it. Cheers – Erbert Jul 24 '14 at 15:15
  • I wonder if it would also be possible, separately to display a page of all the tours but any with the same tour_name are grouped so only the most recent is shown with a list of the alternative dates underneath?? – Erbert Jul 30 '14 at 22:47
  • I believe you can do that using Stash. There's probably this answer already here somewhere. – Sobral Jul 30 '14 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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