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?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
January 13, 2012 10:25am
Subscribe [2]#1 / Jan 13, 2012 10:25am
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
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
Got it, thanks! I did look at the {count} variable and ended up using that for this implementation.
#4 / Jan 14, 2012 6:43am
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.