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.

Displaying two channel entries tags, one with pagination

June 20, 2012 4:58am

Subscribe [2]
  • #1 / Jun 20, 2012 4:58am

    doubleplusgood

    199 posts

    Hi,

    So i’m trying to display a featured entry and then beneath that I want to display all other entries with pagination.

    My ‘featured entry’ displays fine, but I can’t seem to get the other entries with pagination to display at all.

    Here is my code;

    <h3>Featured Case Study</h3>
    <p>{exp:channel:entries channel="case_studies" status="featured" limit="1" dynamic="off"}</p>
    
    <p> {title}</p>
    
    <p>{/exp:channel:entries}</p>
    
    <h3>All Case Studies</h3>
    <p>{exp:channel:entries channel="case_studies" status="open" limit="9" paginate="both"}<br />
      {paginate}<br />
     {pagination_links}<br />
     <div class="pagination"><br />
      <ul><br />
       {previous_page}<br />
       <li><a href="http://{pagination_url}" class="first page-previous">Previous page</a></li><li>//</li><br />
       {/previous_page}<br />
       <br />
       {page}<br />
       <li><a href="http://{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">Page {pagination_page_number}</a></li><li>//</li><br />
       {/page}<br />
       <br />
       {next_page}<br />
       <li><a href="http://{pagination_url}" class="last page-next">Next page</a></li><br />
       {/next_page}<br />
      </ul><br />
     </div><br />
     {/pagination_links}<br />
     {/paginate}</p>
    
    <p> {title}</p>
    
    <p>{/exp:channel:entries}

    Any help with this would be much appreciated. I obviously need the ‘All Case Studies’ to be dynamic for the pagination to work when the entries do finally display.

    The Case Studies page is a Structure managed page at the URI /about-us/case-studies/, which has the about-us/case-studies template assigned to it. This contains the code above.

  • #2 / Jun 21, 2012 10:28am

    Dan Decker

    7338 posts

    Hi Neil,

    Actually? You need dynamic=“no” in your second channel entries tag pair. The addition of the paginate= parameter allows channel entries to “do both” so to speak.

    At least, we need to start with this. I’ve not dealt with pagination and Structure, so I’m not entirely sure the effect that might have.

    I look forward to your reply!

    Cheers,

  • #3 / Jun 21, 2012 11:53am

    doubleplusgood

    199 posts

    Hey Dan, so I would remove dynamic from the first tag pair, add dynamic=“no” to the second channel entries tag pair?

    I’ve changed the template but now no entries are displaying. :/

    I was under the impression that pagination could not work if dynamic was disabled.

  • #4 / Jun 22, 2012 7:12am

    doubleplusgood

    199 posts

    Hmm, this is driving me a bit crazy now.

    Here’s the revised code I am using;

    {embed="_layouts/index"}
    
    {exp:switchee variable="{segment_3}" parse="inward"}
    
     {!-- Case Studies listing --}{!-- Case Studies listing at /about-us/case-studies/ : match pagination, or nothing in segment 3 --}
     {case value="#^P(\\\\d+)$#|''"}
    
      {exp:stash:set name="content"}
    
       <h3>Featured</h3>
    <p>   {exp:channel:entries channel="case_studies" status="featured" limit="1" dynamic="no"}</p>
    
    <p>   {title}</p>
    
    <p>   {/exp:channel:entries}</p>
    
    <p>  </p><h3>Open</h3>
    <p>   {exp:channel:entries channel="case_studies" status="open" limit="9" dynamic="no" paginate="both"}</p>
    
    <p>      {paginate}<br />
         {pagination_links}<br />
         <div class="pagination"><br />
          <ul><br />
              {previous_page}<br />
              <li><a href="http://{pagination_url}" class="first page-previous">Previous page</a></li><li>//</li><br />
              {/previous_page}</p>
    
    <p>          {page}<br />
              <li><a href="http://{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">Page {pagination_page_number}</a></li><li>//</li><br />
              {/page}</p>
    
    <p>          {next_page}<br />
              <li><a href="http://{pagination_url}" class="last page-next">Next page</a></li><br />
              {/next_page}<br />
             </ul><br />
         </div><br />
         {/pagination_links}<br />
         {/paginate}</p>
    
    <p>   {title}</p>
    
    <p>   {/exp:channel:entries}</p>
    
    <p>  {/exp:stash:set}</p>
    
    <p> {/case}</p>
    
    <p>{/exp:switchee}

    It correctly shows the featured case study and the Open case studies, along with the pagination. But when I paginate through the results, the entries don’t change.

  • #5 / Jun 22, 2012 8:19am

    doubleplusgood

    199 posts

    Got a solution now. I had to set the Channel URL and also in Admin > Channel Administration > Global Preferences set the Cache Dynamic Channel Queries? to No.

  • #6 / Jun 22, 2012 3:28pm

    Shane Eckert

    7174 posts

    Hey neilbradley,

    I am glad to see that you got this squared away! Nice work.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases