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 / Entry by Category

October 18, 2010 8:54am

Subscribe [3]
  • #1 / Oct 18, 2010 8:54am

    togs

    9 posts

    Hello,

    I have been stuck on a next entry problem for quite a few hours now, so I am turning to the forums here in the sincere hope that someone can shed some light on where I’m going wrong.

    Essentially, I have a page that lists the last 3 entries for each of about 20 categories. The following is working correctly:

    ———————-

    {exp:channel:categories channel="testimonials" style="linear"}
    
    <b>{category_name}</b>
    
    
    {exp:channel:entries channel="testimonials" category="{category_id}" dynamic="off" disable="member_data" limit="3" paginate="bottom"}
    
      <b>{title}</b>
    
      {exp:word_limit total="30"}
        {testimonial}
      {/exp:word_limit}
      
    
      <a href="http://{url_title_path=testimonial/quickview}">View >></a>
      <hr>
    
    {/exp:channel:entries}
    
    {/exp:channel:categories}

    ———————-

    On the quickview template, I have the following:

    {exp:channel:entries channel="testimonials" disable="member_data" limit="1"}
    
      <h2>{title}</h2>
    
    <p>  {testimonial}</p>
    
    <p>{/exp:channel:entries}</p>
    
    <p>{exp:channel:next_entry channel="testimonials" disable="custom_fields|member_data|pagination"}</p>
    
    <p>  <b>Next Testimonial:</b> <a href="http://{path=testimonial/quickview}">{title}</a></p>
    
    <p>{/exp:channel:next_entry}

    —————————

    Now, if I add category=“6”, (Or any category id) to the channel:next_entry tag it will properly link the next entry that is available in that category. But what I really need, is to get the {category_id} dynamically, based on the category the entry was opened from in the first template.

    The problem is that the quickview template doesn’t have the category url segment that the entry came from, so how do I access it? Do I modify the link from the original template, and if so how do I grab it in the second?

    Perhaps a query is required? I hope not, as using queries in EE would be new territory for me. The various entries could be in multiple categories, so I don’t know if this would be the way to go.

    Anyhow, thank you for reading this post and offering your ideas to get me on the right track. It’s appreciated ...

  • #2 / Oct 19, 2010 1:36am

    togs

    9 posts

    Perhaps I am taking the wrong approach on this?

    Would related entries be a more efficient way, using two channels to be able to achieve the same goal? Is it possible to find the next entry that would have the same relationship?

    Thank you for your input.

    Lovin EE 2, sleepless nights trying to figure it all out though. lol,

  • #3 / Oct 19, 2010 6:33am

    box-head

    177 posts

    I haven’t tested this but you might be able to send through the category_id in the url like so.

    <a href="http://{url_title_path=testimonial/quickview}{category_id}">View >></a>

    Then in the quickview template grab that number using the segment variables.

    {exp:channel:next_entry category="{segment_4}" channel="testimonials" disable="custom_fields|member_data|pagination"}
        <b>Next Testimonial:</b> <a href="http://{path=testimonial/quickview}">{title}</a>
    {/exp:channel:next_entry}

    Forcing the category number in the URL might screw up the single entry but it’s worth a try.

  • #4 / Oct 19, 2010 12:10pm

    John St-Amand

    865 posts

    That’s how i did it with http://www.trevorallen.ca when in the photo gallery section.  When viewing the category thumbnails, I inserted the category_id into the url_title_path as an additional segment, then used that segment in the single photo view template to allow the segment to be used in the next/prev linking.  It’s perhaps not the most transparent way to do it, but it definitely works.

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

ExpressionEngine News!

#eecms, #events, #releases