ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

every third post, add html

January 13, 2012 10:25am

Subscribe [2]
  • #1 / Jan 13, 2012 10:25am

    meredithmarsh

    44 posts

    Is there a way to tell EE that after every third post (or what ever number), inject something. For example if I have a page of 100 entries, and I want to inject a google ad after every third entry.

    Is that possible?

  • #2 / Jan 13, 2012 11:35am

    danieljohnbarnes

    151 posts

    Look at the {count} variable.

    You can use a conditional to check that count is a multiple of 3. You might need to have every multiple of 3 up to your limit without using pHP but it should work. You can also use {total_results} so you’ll know what the maximum is.

    Alternatively, use PHP to increment and insert your code every 3 times.

  • #3 / Jan 13, 2012 1:30pm

    meredithmarsh

    44 posts

    Got it, thanks! I did look at the {count} variable and ended up using that for this implementation.

  • #4 / Jan 14, 2012 6:43am

    John St-Amand

    865 posts

    The switch variable can be used to inject HTML as well at regular intervals without the repetition the switch variable would call for.  Alternatively thee are a few interval-based add-ons that would perform a similar function and allow for slightly cleaner markup.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases