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.

If Next Entry?

September 21, 2011 1:07am

Subscribe [3]
  • #1 / Sep 21, 2011 1:07am

    nikkimarie

    2 posts

    Hi there,
    I’m still pretty new to EE, so sorry if this is elementary.

    I’d like to write a conditional saying that if there is a next entry in this channel, display the link to the next entry. If there isn’t a next entry in the channel, the display something else. Right now if there is no next entry the link just disappears. Can anyone point me in the right direction?

    Here’s the code:

    {exp:channel:next_entry  channel="case_study"}    
        <a href="http://{path=case_studies/detail}">Next Project >></a>
    {/exp:channel:next_entry}

    Thanks!

  • #2 / Sep 21, 2011 11:39am

    Mark Bowen

    12637 posts

    EDIT - Check out Advanced Prev Next Entry as I believe that should allow you to do what you need here.__Hi nikkimarie,__There is nothing built-in to ExpressionEngine to do what you need here I’m afraid. Those links will either show or not show as and when necessary. There isn’t unfortunately an {if next_entry} conditional available to those tags so I don’t think it will be possible with them.__You are welcome to put in a [url=http://ellislab.com/forums/viewforum/106]Feature Request to have this added to those tags if you wish though.

    There may also be a 3rd party add-on available over on devot-ee.com which might be able to help you here too.

    I’m going to move this post down to the Community Help forums in order for other users to see it and it might be that someone has done this before and can let you know how they did it.

    Thanks,

    Mark

  • #3 / Sep 23, 2011 4:01pm

    adlur

    104 posts

    Hi nikkimarie, if you haven’t already solved this problem I was looking to do something similar- put a “|” in between “next” and “previous” links but leave it out if there is no “next” or “previous”. I got it done with a little jquery:

    <div id="pagination_display">
    {exp:channel:next_entry channel="news_ch"}
    <span><a href="http://{path=news/entry}">{title}</a></span>
    {/exp:channel:next_entry}
    
    {exp:channel:prev_entry channel="news_ch"}
    <span><a href="http://{path=news/entry}">{title}</a></span>
    {/exp:channel:prev_entry}
    
    < script >
    // checking to see if there is a previous entry- if so, add the divider after the nextlink
    if ($("#previous").length) {
     $("#next").append('<span> | </span>');
    }
    < /script >
    </div>

    Jquery isn’t my strong suit but as best as I can tell this is looking for “#previous” and if it exists adds

    <span> | </span>

    after “#next”, which also works if there’s no “#next” because even though there’s a “#previous” there’s no “#next” and it can’t append to something that’s not there…

    Hope that helps, in this example I added a space before the “<” and “>” of the script tags because the forum them otherwise…

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

ExpressionEngine News!

#eecms, #events, #releases