Search code examples
phphtmlexpressionengine

prev_entry with ExpressionEngine


I’m having a small problem with the prev_entry tags and ExpressionEngine.

It’s strange as it works on other parts of the site. Basically I have a site with the six latest projects, then a prev_entry and a next_entry to go to the next entry in the list of six.

For some reason, when you hit the end of the entries, the “next entry” link won’t disapear, and when it’s clicked it brings up an empty page… You can see it here:

http://www.mclh.co.uk/index.php/divisions/view/170

If you click the last entry, the arrows still appear. Then, when you click the arrow, it brings you to an empty page. I have another section of the site that uses the exact same code, only thing that is different is the category group and it works fine. Look here:

http://www.mclh.co.uk/index.php/projects/view/199

If you click the last project on that, it disappears as it should do. I’m using the exact same code duplicated, only thing I changed was the category group.

The code is:

    <div id="bottom-content">
        {exp:channel:next_entry category_group="2" category="{categories}{category_id}|{/categories}"}
            <a class="rightNav" href="{id_path='divisions/view'}" style="color:#000;"><<</a>
        {/exp:channel:next_entry}

        <div id="current-project-wrap">
            <div class="current-project">
                {exp:imgsizer:size src="{division_image}" height="68px" width="137px"}
                    <a href="{title_permalink='divisions/view'}"><img src="{sized}" height="{height}" width="{width}" alt=""/></a>
                {/exp:imgsizer:size}
                <a href="{title_permalink='divisions/view'}"><p class="thumbTitle">{title}</p></a>
            </div>
        </div>

        {embed="divisions/related" stop_before="{entry_date format="%Y-%m-%d %H:%i"}" category_id="{categories show_group="1" limit="1"}{category_id}{/categories}"}

        {exp:channel:prev_entry category_group="2" category="{categories}{category_id}|{/categories}"}
            <a class="leftNav" href="{id_path='divisions/view'}" style="color:#000;">>></a>
        {/exp:channel:prev_entry}
    </div>
{/exp:channel:entries}

Any suggestions?

(Yes, I have another issue. This site has gave me nothing but problems from the start (I didn't initially design or develop it).)


Solution

  • Be sure to add channel="channel_name" to the prev_entry and next_entry tags. Otherwise it will include next/prev links to entries from other channels that might share that same category.

    Also, the category_group and category parameters are mutually exclusive, so you don't need both. (category overrides category_group.)