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/Previous entry based on category

April 17, 2011 8:31pm

Subscribe [2]
  • #1 / Apr 17, 2011 8:31pm

    DorinV

    38 posts

    Hi,

    I’ve got a problem with next/prev links.

    I have 2 categories, Blue and Red in one category group.
    I’m displaying both Blue and Red categories on the homepage with “read more”.
    I have a top menu for Blue and Red.

    I want so that when I’m clicking Blue my “read more” page to have as Next/Previous entries only entries from Blue Category, and if it’s possible to add an .active class to the Blue link in the top nav )

    Thank you !

  • #2 / Apr 18, 2011 4:20pm

    Brandon Jones

    5500 posts

    Hi Dorin Vancea,

    Which version of EE are you using? Can you share a simplified template with your pagination code? From the docs:

    Pagination will also automatically restrict itself to any category you’re currently viewing. So if you have a category specified in your channel entries tag or you are viewing the entries of a category, then the pagination links will automatically restrict themselves to only entries in that category.

  • #3 / Apr 18, 2011 5:51pm

    DorinV

    38 posts

    Thank you for your reply.

    Main page where both categories are displayed: index

    {exp:channel:entries channel="portfolio" orderby="date"  limit="50" }
    <div class="box col">
    <a href="http://{title_permalink=webpage/details}class=details"><span class="fade"></span></a>
    {thumb}
    </div>
    {/exp:channel:entries}

    When you click on one of the items it will take you to: details

    {exp:channel:entries channel="portfolio" orderby="date" limit="1" sort="desc" }
    <h1>{title}</h1>
    {description}
    <div class="tags">{tags}</div>
                                    
    {if link != ""}<a href="http://{link}%22class=%22visit" class="visit" target="_blank" rel="noopener"></a>{/if}
    </div><!-- /topcontent -->
    <div class="content">{screenshoots}</div>
    {/exp:channel:entries}

    and next/prev entry in: details

    {exp:channel:next_entry}
    <a href="http://{path=webpage/details}class=next"></a>
    {/exp:channel:next_entry}
    
    {exp:channel:prev_entry}
    <a href="http://{path=webpage/details}class=back"></a>
    {/exp:channel:prev_entry}
  • #4 / Apr 19, 2011 4:57pm

    DorinV

    38 posts

    Solve the problem:

    I did a separate template for each category and link to them from the homepage like this:

    {categories}
    {if category_id == "2"}
    {title_permalink='webpage/experiments_details'}
    {/if}
            
    {if category_id == "1"}
    {title_permalink='webpage/webdesign_details'}
    {/if}
    
    {/categories}

    Took me few hours to figure out but I’m happy with the result.

  • #5 / Apr 19, 2011 4:59pm

    DorinV

    38 posts

    One more thing please.

    How do I get rid of the Template Group in Url ?

  • #6 / Apr 19, 2011 11:04pm

    Lisa Wess

    20502 posts

    Glad you found a solution, Dorin!

    The template group is a vital part of ExpressionEngine, especially for 404s.  You can leave it out when referencing the index template of the default template group (the one with the asterisk); but in general, we recommend always including the template group.

    Does that help answer your question?

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

ExpressionEngine News!

#eecms, #events, #releases