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.

Single Entry - Next / Prev with Categories and back to list view?

August 16, 2011 11:55am

Subscribe [1]
  • #1 / Aug 16, 2011 11:55am

    iDVB

    56 posts

    I’m sure I’m almost there. I’m also sure there has got to be a post somewhere in the forums where this is answered. However, I gave myself 3 days to search and figure this one out before posting and I still am not there.

    Requirements / What I’m tring to do:
    1) user comes to this single entry page and category is in URL OR maybe there is no category specified
    2) user clicks prev or next buttons and sees the next single entry in the current category (if specified) if not… it cycles all entries in all categories.
    3) user clicks Back to List and they are sent back to the listview template and the category is also passed.

    What I’ve tried:
    1) Using {if category_request}/{segment_4}{/if} to append to next and previous buttons.
    Issue: Is this really needed?
    2) Filtering {exp:channel:prev_entry} & {exp:channel:next_entry} by category based on the {exp:channel:category_heading channel='projects'}{category_id}{/exp:channel:category_heading}
    Issue: placing all that in the category param of the next and prev tags seems rather excessive and does not seem to work. Wrapping the whole pagination in the heading tag and only putting the {category_id} in the next prev tags does seem to work but then IF no category is specified then my requirement #2 is not possible as the prev and next are hidden.

    Example URL to this template: http://domain.com/index.php/projects/details/56/C6

    {exp:channel:entries channel="projects" order_by="date" sort="asc" dynamic="yes"}
    <div class="category_header">
        <h3>{title}</h3>
    <p>    </p><h4>{category_name}</h4>
    <p></div><br />
    <ul class="prevnext_nav"><br />
        <li>{exp:channel:prev_entry channel="projects" category="{exp:channel:category_heading channel='projects'}{category_id}{/exp:channel:category_heading}"}<a href="http://{id_path=%27projects/details%27}{if">/images/back.gif</a>{/exp:channel:prev_entry}</li><br />
        <li><a href="http://{path=%27projects{if">/images/BackToThumbs.gif</a></li><br />
        <li>{exp:channel:next_entry channel="projects" category="{exp:channel:category_heading channel='projects'}{category_id}{/exp:channel:category_heading}"}<a href="http://{id_path=%27projects/details%27}{if">/images/forward.gif</a>{/exp:channel:next_entry}</li>    <br />
    </ul></p>
    
    <p><div class="project_item"><br />
        <div class="image_area"><br />
            {exp:channel_images:images entry_id="{entry_id}"}<br />
            {image:url:medium}<br />
            {/exp:channel_images:images}<br />
        </div><br />
        ID:AM{category_url_title}{entry_id}<br />
        Description:{project_body}<br />
    </div><br />
    {/exp:channel:entries}

  • #2 / Aug 16, 2011 2:33pm

    iDVB

    56 posts

    —UPDATE—

    Ok, so I ended up doing the following, and it works, but seems very ugly. I’m very much interested in feedback or cleaner process if there is one.

    {exp:channel:entries channel="projects" order_by="date" sort="asc" dynamic="yes"}
    <div class="category_header">
        <h3>{title}</h3>
    <p>    </p><h4>{category_name}</h4>
    <p></div><br />
    <ul class="prevnext_nav"></p>
    
    <p>{if category_request}<br />
    {exp:channel:category_heading channel='projects'}<br />
        <li>{exp:channel:prev_entry channel="projects" category="{category_id}"}<a href="http://{id_path=projects/details}/C{category_id}">/images/back.gif</a>{/exp:channel:prev_entry}</li><br />
        <li><a href="http://{path=projects/C{category_id}}">/images/BackToThumbs.gif</a></li><br />
        <li>{exp:channel:next_entry channel="projects" category="{category_id}"}<a href="http://{id_path=projects/details}/C{category_id}">/images/forward.gif</a>{/exp:channel:next_entry}</li>    <br />
    {/exp:channel:category_heading}<br />
    {/if}<br />
    {if not_category_request}<br />
        <li>{exp:channel:prev_entry channel="projects"}<a href="http://{id_path=projects/details}">/images/back.gif</a>{/exp:channel:prev_entry}</li><br />
        <li><a href="http://{path=projects}">/images/BackToThumbs.gif</a></li><br />
        <li>{exp:channel:next_entry channel="projects"}<a href="http://{id_path=projects/details}">/images/forward.gif</a>{/exp:channel:next_entry}</li><br />
    {/if}                </p>
    
    <p></ul></p>
    
    <p><div class="project_item"><br />
        <div class="image_area"><br />
            {exp:channel_images:images entry_id="{entry_id}"}<br />
            {image:url:medium}<br />
            {/exp:channel_images:images}<br />
        </div><br />
        ID:AM{category_url_title}{entry_id}<br />
        Description:{project_body}<br />
    </div><br />
    {/exp:channel:entries}

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

ExpressionEngine News!

#eecms, #events, #releases