1

I'm trying to get my head around EE so please bear with me on something probably simple:

How do you loop through a EE entries chunk and append a number? Like a id="blogitem-1", id="blogitem-2", id="blogitem-3"... there may be no end to the numbering.

I have a blog section that requires each hidden ID be sequential. I got the jquery popover working using {entry_id} but I need to go forwards and backwards and the pager doesn't work. I cheated a little using {switch="1|2|3|4"}... but that's really ugly and it has a fixed end.

Here's the code snippet:

{exp:channel:entries
    channel="blog"
    disable="category_fields|member_data|pagination|trackbacks"
    status="Open"
    dynamic="no"
    paginate="bottom"                
}
<!-- This is a blog item -->
<div class="blogitem-content hidden" id="blogitem-{entry_id}">
    <img src="{base_image:blogimg}" alt="{title}">
    <h2 class="primary-color">{title}</h2>
    <h3>{subtitle}</h3>
    {body}              

    <ul class="pager">
        <li class="previous"><a href="#blogitem-2" class="">&larr; Previous</a></li>
        <li class="next"><a href="#blogitem-4" class="">Next &rarr;</a></li>
    </ul>              

</div>
<!-- / Blog item -->
{/exp:channel:entries}

This shows what could be entry #3, with the pager linking to the previous id (#2) and the next (#4). While "{entry_id}" lets me pop-up the post, I can't navigate.

I also don't want to expose PHP to the template (not understanding PHP too much I don't want to open up something that can bite me later). I can't seem to generate a simple progressive 1, 2, 3... for the id.

I'm learning EE and a bit of jQuery, so sorry if this is elementary

4

You can use {count} or {absolute_count}, instead of {entry_id}. {count} restart on every page, while {absolute_count} increases across pagination.

By the way, 'tackbacks' isn't a value of the disable parameter.

5
  • Thanks! I tried {count} before but I must have done something wrong - much appreciated. On trackbacks, I'm using a EE styling plugin for Textmate and it was a default on expansion - maybe a holdover from EE1? Now all I need to do is figure out how to do math and increment up and down 1 record for the pager…
    – Kel
    May 12 '13 at 22:06
  • As a point, I found a math plugin to do the incrementing-decrementing.
    – Kel
    May 12 '13 at 22:13
  • If all the ID numbers are sequential, I really don't see any reason for you to worry about the IDs of the pagers. Is really easy to do the math and find them.
    – Sobral
    May 12 '13 at 22:26
  • Do the math on JS, I mean!
    – Sobral
    May 13 '13 at 0:31
  • Actually, the id's aren't sequential as they're coming from a field using the new relationship tool, and the user is setting the order themselves. I used "blog" only as an example. @Robert - again, early days, but I wanted to do things within each embed
    – Kel
    May 13 '13 at 5:58

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.