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.

Pagination issues with segment HELP

November 28, 2014 8:25am

Subscribe [2]
  • #1 / Nov 28, 2014 8:25am

    Eastwood Design

    605 posts

    I have a template for a blog. 

    When there is no segment_2 the template serves up a list of blog entries. Clicking on the entry reloads the page with the url_title as segment_2 and displays just the one entry

    I use if conditions to check for segment 2 and if it is there it displays the entry.

    PROBLEM:
    When I use pagination and click on the next page and get /P6 as segment_2 so I do not get the second page of entries but rather a single entry.

      How do I use a single template to display a blog list, a single blog entry and use pagination?

    {if segment_2} 
    {exp:channel:entries channel="commentary" entry_url="{segment_2}" limit="1" dynamic="yes" disable="member_data|pagination"}
    {BLOG}
    {/exp:channel:entries}
    {/if:else}
    {exp:channel:entries channel="commentary" show_future_entries="no" limit="12" dynamic="no" paginate="bottom"}
    <a href="http://{title_permalink=commentary}">{title}</a>
    
    {paginate}
            Page {current_page} of {total_pages} pages {pagination_links}
        {/paginate}
    
    
    {/exp:channel:entries}
    {/if}

     

  • #2 / Nov 28, 2014 9:51am

    worfoual

    61 posts

    You could use the add-on switchee and the code look like this:

    {exp:switchee variable="{segment_2}" parse="inward"}
    
    {!-- --------------------------------- All items ----------------------------------------------  --}
    
    {case value="#^P(\\\\d+)$#|''"}
    
    {exp:channel:entries channel="commentary" show_future_entries="no" limit="12" dynamic="no" paginate="bottom"}
    <a href="http://{title_permalink=commentary}">{title}</a>
    
    {paginate}
            Page {current_page} of {total_pages} pages {pagination_links}
        {/paginate}
    
    
    {/exp:channel:entries}
    
    {/case}
    
    {!-- --------------------------------- EINDE Alle  NIEUWS items ----------------------------------------------  --}
    
    
    {!-- -------------------------------------------------1 selected item ---------------------------  --}
     {case default="Yes"}
    
    {exp:channel:entries channel="commentary" entry_url="{segment_2}" limit="1" dynamic="yes" disable="member_data|pagination"}
    
    {BLOG}
    
    {/case}
    
    {/exp:switchee}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases