Modifying news_short to include banners every n posts
Hello
I'm stuck trying to figure out how I can modify news_short to have a counter or something so I can have it insert an ad banner every n posts. I got stuck trying to figure out what controls the news_short looping each time which is probably where I want to throw the code in for the counter variable. Help appreciated!
Re: Modifying news_short to include banners every n posts
I looked at news_short, it does not contain any loops. Isn't this the template for a single item? Try looking at mod_newslist insted. It loops articles, so inserting something every x articles would be possible. Be cautious though, I hardly ever use that module myself, so fairly unsure how it operates.
Re: Modifying news_short to include banners every n posts
Wanted the same behaviour on my side. After every third news item I wanted a banner.
I solved this by creating a single front end module for the banners and creating 5 front end modules for the news items. The news modules or configured to skip the first 0, 3, 6, 9 or 12 news items and only show 3 items.
After this I placed these front end modules in the page layout in the correct order (see attachment)
This worked for me...
Re: Modifying news_short to include banners every n posts
Not a bad solution, actually...
It also looks like there is a $this->count that you can use inside your news_short template (starts with "1")...
Code:
<?php if (!$this->count % 4): ?>
<?php else: ?>
<?php endif; ?>
Re: Modifying news_short to include banners every n posts
Quote:
Originally Posted by Medianomaly
Not a bad solution, actually...
It also looks like there is a $this->count that you can use inside your news_short template (starts with "1")...
Code:
<?php if (!$this->count % 4): ?>
<?php else: ?>
<?php endif; ?>
Should be like this, otherwise one news item is skipped, right?
Code:
<?php if (!$this->count % 4): ?>
<?php endif; ?>
Re: Modifying news_short to include banners every n posts
Quote:
Originally Posted by Ruud
Should be like this, otherwise one news item is skipped, right?
Ahh yes -- thanks.
Re: Modifying news_short to include banners every n posts
Wow so simple. Thank you so much guys! $this->count for the win!
I'll be back, forums rock
Re: Modifying news_short to include banners every n posts
both forums and <?php print_r($this); ?>
If you ever need to know available options that's a quick start to see available data in objects and arrays...