0

I've been trying to find a proper way to do this but no luck so far. How does one go filtering products in Cartthrob. For example if the user wants to change the number of products displayed by clicking the relevant link (show items: 16, 64) (limit=16, limit=64 and so on). I've tried using Mo'variables and pass a limit variable on the url (i.e. /books?limit=16) however this messes up pagination and category filtering. Is there a guide or something on how to achieve this without loosing your hair? :)

0

You're on the right track. This advice applies to EE 2.7.2+, so if you're on an earlier version of EE, sorry. First, you don't need to use Mo' Variables. All you need to do is set the dynamic_parameters="limit". Now when limit=X is in your url query string, the channel:entries loop will automatically use that limit. To get it to work with pagination, you need to do this (add the query string to the pagination links):

{paginate}
  {pagination_links}
    <ul>
      {page}
        <li><a href="{pagination_url}{if current_query_string}?{current_query_string}{/if}">{pagination_page_number}</a></li>
      {/page}
    </ul>
  {/pagination_links}
{/paginate}

Docs on dynamic parameters: http://ellislab.com/expressionengine/user-guide/modules/channel/dynamic_parameters.html

Docs on current_query_string global variable: http://ellislab.com/expressionengine/user-guide/templates/globals/single_variables.html#current-query-string

| improve this answer | |
  • Its working but with multiple variables it becomes a mess. Have to change the pagination_base and check if a query string exists and so on. It is messy! Especially when filtering by categories and have to keep the url along with the query_string and pagination url... – diadyo Jan 23 '14 at 15:51

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.