Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-03-30 11:11:26

december76
Member
From: Malmö, Sweden
Registered: 2004-05-18
Posts: 45
Website

Displaying ads in article lists

Hello, all!

I’m currently trying to implement Google ads on my site. On my front page I use a simple article list (txp:article /> list displaying ten articles from different sections. In this list of articles I would like to display an ad after every five articles, like this:

  • article
  • article
  • article
  • article
  • article
  • Ad
  • article
  • article
  • article
  • article
  • article
  • Ad

Conceptually I guess I would like the form containing the separate article (the default form) to be able to add the code for the ad, when the number of previously displayed articles reaches the number five. A counter of sorts, I suppose.

Is there any way of achieving anything like this?

Offline

#2 2008-03-30 11:49:26

december76
Member
From: Malmö, Sweden
Registered: 2004-05-18
Posts: 45
Website

Re: Displaying ads in article lists

I found a simple, and rather obvious solution. Instead of trying to make the article form counting displayed articles I changed the page template to this:

<txp:article limit="1" pageby="10" />
<Google code>
<txp:article limit="5" offset="1" pageby="10" />
<Google code>
<txp:article limit="4" offset="6" pageby="10" />

This will display a list of ten articles, with an ad after the first and sixth one.

You may see the result here if you like.

Last edited by december76 (2008-03-30 12:05:38)

Offline

Board footer

Powered by FluxBB