3

On a template I am calling in a series of snippets like so:

{sn-head}

{sn-header}

{sn-page}

{sn-listing-videos}

{sn-footer}

The sn-listing-videos snippet contains an entries loop like so:

{exp:channel:entries channel="video" limit="12" paginate="both" disable="categories|member_data" dynamic="no"}

    {sn-listing-pagination}

    {title}
{/exp:channel:entries}

The sn-listing-pagination snippet isn't rendering in this instance. In fact, none of my snippets are rendered with the sn-listing-videos snippet at all.

I have a few other templates which contain listing snippets for other channels which contain the same code apart from the channel parameter in the exp:channel:entries tag - and the pagination snippet works just fine in these.

I am using the SnippetSync module. I have run a test after having uninstalled it, but still no luck.

What could cause this problem for that particular template/snippet?

=================

EDIT:

Here's the code for a different listings page where the same set up works.

Template code:

{sn-head}

{sn-header}

{sn-page}

{sn-listing-resource}

{sn-footer}

sn-listing-resource snippet code:

{exp:channel:entries channel="resource" limit="5" paginate="both" disable="categories|member_data" dynamic="no"}
    {sn-listing-pagination}

    {title}
{/exp:channel:entries}

=================

EDIT #2:

Content of pagination snippet:

{paginate}
      <div class="listing-pagination">
          {pagination_links}
            {previous_page}
              <a href="{pagination_url}">Prev</a>
            {/previous_page}

            {page}
              <a href="{pagination_url}" {if current_page}class="active"{/if}>{pagination_page_number}</a>
            {/page}

            {next_page}
              <a href="{pagination_url}" class="button slim next">Next</a>
            {/next_page}
          {/pagination_links}
      </div>
{/paginate}
  • Also, can you post the snippet of {sn-listing-pagination} – Siebird Oct 30 '13 at 18:19
  • Question, in your Videos channel, is there more than 12 entries? – Siebird Oct 30 '13 at 18:48
  • There's two video entries. I've tried changing the limit to '1' to force pagination, but that didn't change anything :( – Katrin Oct 30 '13 at 19:38
  • I would try adding more than 2 videos to the channel and then test on a limit higher than 1 – Siebird Oct 30 '13 at 19:43
  • @Katrin, updated my answer below for you. – Stephen Callender Oct 30 '13 at 20:23
3

This is due to the parse order. EE parse snippets at a very early stage all at once, hence not being able to have a snippet within a snippet. I suggest removing the {sn-listing-pageination} and just hard code that in the {sn-listing-videos}.

Or you could convert all your snippets/variables over to Low Variables and set the {sn-listing-pagination} to a early parsed variable. This will then parse before the {sn-listing-video}

| improve this answer | |
  • Feel free to check out this handy guide too! When I run into this issue I always turn to the Low Parse Guide! loweblog.com/downloads/ee-parse-order.pdf – Mark Busnelli Jr Oct 30 '13 at 16:52
  • I am aware of the parse order, I'm just not quite sure I understand the implications of this in this instance. You say you can't have a snippet within a snippet, but the same set up works in three other listing snippets. How's that possible? – Katrin Oct 30 '13 at 17:20
  • Please post the working code in your question above. Most likely it's being used slightly different. – Siebird Oct 30 '13 at 18:02
  • Done. I just copied and pasted the working code and changed the channel and limit parameters. – Katrin Oct 30 '13 at 18:24
  • This isn't true. See my answer for a detailed explanation. – Stephen Callender Oct 30 '13 at 20:24
0

I was just able to accomplish what you're after using Snippet Sync AND the problem (see below).

In EE template, I have just:

{sn:snippet_1}

In sn:snippet_1, I have:

{exp:channel:entries channel="pages" limit="1" paginate="both" disable="categories|member_data" dynamic="no"}
  {sn:pagination}
  {title}<br>
{/exp:channel:entries}

In sn:pagination, I have:

{paginate}
  <div class="listing-pagination">
      {pagination_links}
        {previous_page}
          <a href="{pagination_url}">Prev</a>
        {/previous_page}

        {page}
          <a href="{pagination_url}" {if current_page}class="active"{/if}>{pagination_page_number}</a>
        {/page}

        {next_page}
          <a href="{pagination_url}" class="button slim next">Next</a>
        {/next_page}
      {/pagination_links}
  </div>
{/paginate}

My output is:

<div class="listing-pagination">
  <a href="http://www.starterslab.local" class="active">1</a>
  <a href="http://www.starterslab.local/P1" >2</a>
  <a href="http://www.starterslab.local/P2" >3</a>
  <a href="http://www.starterslab.local/P1" class="button slim next">Next</a>
</div>

Inner Page

<div class="listing-pagination">
  <a href="http://www.starterslab.local" class="active">1</a>
  <a href="http://www.starterslab.local/P1" >2</a>
  <a href="http://www.starterslab.local/P2" >3</a>
  <a href="http://www.starterslab.local/P1" class="button slim next">Next</a>
</div>

HOWEVER, if I put my pagination code inside of sn:snippet_1 and my channel entries code into sn:pagination I get this unparsed code:

{paginate}
  <div class="listing-pagination">
      {pagination_links}
        {previous_page}
          <a href="{pagination_url}">Prev</a>
        {/previous_page}

        {page}
          <a href="{pagination_url}" >{pagination_page_number}</a>
        {/page}

        {next_page}
          <a href="{pagination_url}" class="button slim next">Next</a>
        {/next_page}
      {/pagination_links}
  </div>
{/paginate}

Here's why: Snippets are parsed in order among themselves. So, make sure your sn-listing-pagination snippet is listed after/below sn-listing-videos in EE. If not, create a new snippet for it so that it is parsed at the end.

To further illustrate, below is a view of my exp_snippets table (not used the example above). Note the snippet_id column. Snippets are parsed in order, from 1 to whatever you have.

So, you can embed snippet id 7 into 1 and it will parse since 7 is parsed after 1. You can't do the reverse. When snippet 7 is parsed, if snippet 1's tag is embedded it will just come back unparsed, since snippet 1 has already been parsed. It won't know to re-parse it.

enter image description here

| improve this answer | |
  • Now, I'm curious! Do you mind of explain a little better your conclusion? – Robson Sobral Oct 30 '13 at 20:41
  • Sure. I'll throw in some for you. :) – Stephen Callender Oct 30 '13 at 20:48
  • Wow! This is amazing, but we should talk to somebody at EllisLab if we can rely on this. Since it's undocumented, this can change without warning. – Robson Sobral Oct 30 '13 at 21:18
  • Thank you for taking the time to test and explain this in such detail, I really appreciate that. I have deleted the pagination snippet and created it again. I looked at the exp_snippets table and it had a higher ID (47) than the listing snippet (46), but that didn't change anything. I did realise that the video listing snippet had a site_id of 1 and all the others had a site_id of 0 - which is very odd and I assume a glitch from the SnippetSync add-on. Here's a screenshot of the table. – Katrin Oct 31 '13 at 12:28
  • 1
    I just asked EllisLab about this. They don't have plans to change this behavior, but they don't recommend to rely on this unless you have a massively pressing need to nest snippets, due to the lack of official support. – Robson Sobral Oct 31 '13 at 16:52

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.