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.

Next Entry with only URL title

December 09, 2013 5:37pm

Subscribe [2]
  • #1 / Dec 09, 2013 5:37pm

    Cartegraph

    83 posts

    I need a way to access the next entry of a current entry. Normally this is easy, however because of how I need to structure the URL I have to query like so, {exp:channel:entries url_title="{segment_3}”} to get the article. This breaks how EE natively handles the next_entry tag pair.

    I’ve tried multiple plugins, which all won’t work because I need to have access to Channel Images fields.

    Is there any way to use the exp:query tag to get the next entry?

    Thanks!

  • #2 / Dec 11, 2013 2:11pm

    moki

    26 posts

    Can’t you just pass in the url_title to the {exp:channel:prev_entry} tag?  As per the EE docs:

    http://ellislab.com/expressionengine/user-guide/modules/channel/entry_linking.html

    url_title=

    url_title=”{segment_4}”

    You may specify the URL title in which the module uses as a reference for next and previous entries. This is useful when a custom URL structure is being used and the module has trouble detecting the URL title automatically.

  • #3 / Dec 12, 2013 9:58am

    Cartegraph

    83 posts

    I can, and I have to. However without the entry being queried dynamically through the url it seems that next_entry won’t work.

    I have found a solution. It uses the entry_linking plugin and exp:query.

    {exp:entry_linking entry_id="{entry_id}” link=“previous” channel=”{segment_2}” sort=“DESC” status=“open” mode=“full” no_results=“cycle”}

    {exp:query sql="SELECT entry_id AS id, filename FROM exp_channel_images WHERE entry_id < {entry_id} AND channel_id = {channel_id} ORDER BY id LIMIT 1”}{exp:low_replace find=".jpg" replace="__hero.jpg"}{site_url}/assets/img/learn/covers/{id}/{filename}{/exp:low_replace}{/exp:query}

    Hope this helps someone else.

  • #4 / Dec 12, 2013 11:34am

    moki

    26 posts

    I ended up doing something a bit different, which worked for me even though the EE docs say it won’t work inside of the {exp:channel:entries} loop.  This is a fragment of an embed:

    <!—The Next button—>

    {exp:channel:entries channel="{embed:which_channel}” limit=“1” orderby=“date” sort=“desc” status=“Open|preview_secret” dynamic=“no”}
    {if url_title == segment_2}
    <!—This is the first entry in the channel—>
      {exp:channel:prev_entry channel="{embed:which_channel}”}
      <div class=“pan-right-next picWide btn-next-index”>
      /site/assets/site/[email protected]
      </div>
      {/exp:channel:prev_entry}
    {if:else}
    <!—This is NOT the first entry in the channel—>
      {exp:channel:prev_entry channel="{embed:which_channel}”}
      <div class=“pan-right-next picWide btn-next”>
      /site/assets/site/[email protected]
      </div>
      {/exp:channel:prev_entry}
    {/if}
    {/exp:channel:entries}

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

ExpressionEngine News!

#eecms, #events, #releases