3

I'm using this code to display the active category as the title of the page before the channel entries are listed out, however, if you go to the next page using the pagination the category seems to lose it's active status and nothing is returned. Any suggestions?

Example:

1st page returns: Category > Active Category Name

2nd page returns: Category >

1st page URL: /sustainability/stories_and_video/category/pillars_passion_for_people

2nd page URL: /sustainability/stories_and_video/category/pillars_passion_for_people/P3

{exp:channel:entries channel="stories" disable="member_data" orderby="article_publish_date" sort="desc" limit="3" pagination="bottom"}
  {if count == 1}
      <h2>
           Category > {categories}{if active}{category_name}{/if}{/categories}
      </h2>
  {/if}
  <div class="pageBlock newsBlock">
    {if story_image != ""}<img class="sus_small_img" src="{story_image:small_images}" />{/if}
    <h2><a href="{page_url}">{title}</a></h2>
    {story_blurb}
    <span id="more"><a href="  {url_title_path='sustainability/story_detail'}">Read more</a></span>
</div>
{paginate}
    <p>Page {current_page} of {total_pages} pages {pagination_links}</p>
{/paginate}
{/exp:channel:entries}

1 Answer 1

2

I haven't used the active variable before so I'm not sure why it's not working with pagination, however you should be able to use the segment variable in your conditional instead:

{categories}
    {if category_url_title == segment_4}{category_name}{/if}
{/categories}
2
  • I figured that would be my work around if I couldn't resolve this, but just thought I would throw it out there in the interest of keeping everything as dynamic as possible. :) Thanks for your suggestion! Mar 22, 2013 at 15:54
  • Okay, I responded to this before I had my coffee... this solution IS dynamic and is exactly what I needed. Thank you! Mar 22, 2013 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.