1

I want to use pagination to paginate article in the "news" section but only those that have a "Yes" statement in the calendar_add field. calendar_add is a switch (pill) field where you can choose from Yes and No.

Pagination does not work. If I remove {if calendar_add == "Yes"} is works fine but paginates all the entries.

Here is the code:

{exp:channel:entries channel="news" limit="1" status="open" orderby="date" sort="desc" disable="categories|category_fields|member_data|trackbacks""} 

    {if calendar_add == "Yes"}

      {title}

      {paginate}
           {exp:string:set name="pagination"}
        {if next_page}
            <a class="button pagination" href="{auto_path}">NESTE SIDE »</a>
        {/if}
        {if previous_page}
            <a class="button pagination" href="{auto_path}">« FORRIGE SIDE</a> &nbsp;
            {/if}
        {/exp:string:set}
      {/paginate}

      {/if}
      {/exp:channel:entries}
      <div class="article-block">{embed="hjem/pagination"}</div>
1

Try using the search tag instead of the conditional. (Make sure the field is set to searchable in the field settings)

{exp:channel:entries channel="news" limit="1" status="open" orderby="date" sort="desc" disable="categories|category_fields|member_data|trackbacks" search:calendar_add="Yes"} 

Alternatively you could move the pagination links outside of the conditional so it showed all the time but that would show blank pages if an entry was not marked yes.

| improve this answer | |
  • Using the search tag did the trick. I was unaware of that tags usage. Thanks a lot :) – Kippi Aug 22 '14 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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