I have deployed pagination to one of templates which should to display only 4 products on a page. Index for that template looks like:

{embed="includes/.header-product" body_color="#FFFFFF"}

        {if segment_3}{embed="includes/.nav-main"}{product}{/if}
        {if segment_2 && segment_3==""}{embed="includes/.nav-main-subcategory"}{subcategory}{/if}
        {if segment_1 && segment_2==""}{embed="includes/.nav-main"}{category}{/if}


Switchee version of code above:

{embed="includes/.header-product" body_color="#FFFFFF"}

    {!-- Category view --}
    {if segment_1 && segment_2==""}{embed="includes/.nav-main"}{category}
        {!-- /Category view --}

        {exp:switchee variable="{segment_3}" parse="inward"}

        {case value="#^P(\d+)$#|''"}

        {!-- Subcategory view --}
            {case value=""}
            {!-- /Subcategory view --}

            {!-- Single product view --}        
            {case default="Yes"}
            {!-- /Single product view --}



and subcategory snippet code looks like:

<div class="container category">

    <div class="row row-category">

    {exp:channel:entries channel="products" category="{segment_2_category_id}" orderby="title" sort="asc" limit="4" paginate="bottom" dynamic="no"}

        {if no_results}
                <div class=""><p>No entries yet.</p></div>

            <div class="col-md-3 col-sm-6 category-item">
                <a href="{site_url}{segment_1}/{segment_2}/{url_title}">
        {product_image limit="1"}
                <img src="{product_image:image}" alt="{product_image:title}" class="img-responsive">

    {switch='|||</div><div class="row row-category">'}

        <p>Page {current_page} of {total_pages} pages {pagination_links}</p>




First page is OK but other pages comes blank. I think I have done something wrong within index or template structure for furniture group but no clue what can be wrong.



1 Answer 1


It seems likely that the conditional that you're using to insert your "subcategory" is getting tripped up by the presence of the segments that pagination would automatically create - segment 3 for example might be blank on your index view, but once you paginate, it's likely occupied, and as such, the terms of your condition can't be met and therefore your listing embed isn't being inserted at all. You may have an easier time with it if you use the excellent switchee add-on which could parse your conditionals earlier using switch case and allow you to detect pagination segments using regex (see the example on the devot-ee page for details).

And to Derek's point - if you don't need an embed - which you would only need if you have a need to either pass a variable (which you're not doing, based on your code), or work around native parse order - you likely could do the same thing with snippets instead and save on performance.

  • I thought that it must be something with that index file at the first point. Regarding using snippets it is good idea, but as I mentioned above my knowledge about EE comes from that book. But it is not too late to learn proper way ;) Jan 28, 2014 at 14:09
  • When moved code to snippet if no_results is not working. Any clue? Jan 28, 2014 at 16:30

Your Answer

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

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