1

I'm currently working on an EE site (2.5.5) and I currently have a setup in place where there are next/prev buttons displayed on the singular view templates for articles (Two channels: Articles & Interviews). The buttons link you chronologically from entry to entry spanning across channels which is great.

{exp:channel:entries channel="articles|interviews|travelling_tips"}
{exp:entries_list per_page="1" entry_id="{entry_id}" entry_series="{embed:all}"}
  {if previous_entry_title}
    <a class="content-nav prev" href="{previous_entry_channel_url}view/{previous_entry_url_title}">Previous Entry: {previous_entry_title}<span></span></a>
  {/if}
  {if next_entry_title}
      <a class="content-nav next" href="{next_entry_channel_url}view/{next_entry_url_title}"><span></span> Next Entry: {next_entry_title}</a>
  {/if}
{/exp:entries_list}
{/exp:channel:entries}

And the embed from the articles/view template (also interviews/view template):

{embed="embeds/related-articles" 
    entry_id="{entry_id}"
    categories="{categories backspace='1'}{category_id}|{/categories}"
}

Where I'm running into a problem is when the client has a very specific set of criteria on how these buttons work.

If a user uses the search field and then clicks on an article from the search results page, she wants the next/prev buttons to only click through THE SAME channel bringing up more relevant stories. Currently in the search results if you click on an article it will take you to the articles/view template.

My question is how would I best approach this? Would have have to make some sort of new view like search/view to display that article?

Thank you for your time! If I need to rephrase, please let me know.

EE 2.5.5 Entries List 4.2.2

2 Answers 2

1

I though a lot about this, but the only solution I found will cause another issue that you'll have to fix too.

You'll have to add a segment as marker to you URL. For example, add 'search-results' to the links of all entries on search results pages. Since, I've never used Laisvunas Entries List, I'm gonna use the default tags on my sample code. The idea is the same.

On the single entry page:

{embed="embeds/related-articles" channels="{if last_segment == 'search-results'}{channel_short_name}{if:else}articles|interviews|travelling_tips{/if}" from-search=""}

You should put this inside exp:channel:entries tag.

If you prefer to put the next/previous links outside exp:channel:entries, you don't need to use an embed. Use a snippet, instead, and grab the current channel from a segment or using a segment and a conditional.

On the embed template:

{exp:channel:next_entry channel="{embed:channels}"}
    <p>Next entry: <a href="{channel_url}/view/{url_title}{if last_segment == 'search-results'}/search-results{/if}">{title}</a></p>
{/exp:channel:next_entry}

{exp:channel:prev_entry channel="{embed:channels}"}
    <p>Previous entry: <a href="{channel_url}/view/{url_title}{if last_segment == 'search-results'}/search-results{/if}">{title}</a></p>
{/exp:channel:prev_entry}

Of course, this will cause a problem. Your site is gonna have duplicated content: "{channel_url}/view/{url_title}" and "{channel_url}/view/{url_title}/search-results" points to the same page.

To avoid SEO issues, you have to specify the canonical links for this pages without the '/search-results' segment. There are some useful tips about canonical links in this article, too.

I'm sorry. This is the only solution I can think about.

0

Good job getting the channels to play nicely with each other.

The simplest way to do this might just be to create two templates. One for Articles and the other for Interviews. "/view/article/[entry] and /view/interview/[entry]". You could use snippets inside if you wanted to manage that content in the same place.

When you search you might have to do something to differentiate the two channels like:

<a href="/view/{if channel == "article"}article/
                {if:else}interview/
                {/if}{url_title}"> View</a>

This saves you from having to custom write a lot of tests and use other plugins

Your Answer

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

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