Results 1 to 8 of 8

Thread: Modifying news_short to include banners every n posts

  1. #1
    New user
    Join Date
    08-29-11.
    Posts
    2

    Default 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!

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default 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.

  3. #3
    New user
    Join Date
    08-17-11.
    Location
    The Netherlands
    Posts
    9

    Default 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...

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default 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; ?>
    Brian

  5. #5
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default 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; ?>

  6. #6
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default 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.
    Brian

  7. #7
    New user
    Join Date
    08-29-11.
    Posts
    2

    Default 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

  8. #8
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default 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...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •