Inject Ads into Teaser List

RKopacz's picture

I am looking for a module or method to inject banner ads (these would be direct sales banner ads, sold and placed by the site owner, not Google Adsense ads, etc.) into a teaser list at a certain spot in a teaser list (for example, the default front page when Articles are promoted to the front page). For example, I would like a banner ad to appear after the third teaser listed on the front page.

This seems like a desired function, but I cannot seem to find a module or even an example function that would provide this. If anyone has any ideas on where I could find something like this I would appreciate it.

Comments

I actually have code kinda,

bleen18's picture

I actually have code kinda, sorta almost working for this: stay tuned to this issue in the next week or so: http://drupal.org/node/1845990

Great!

RKopacz's picture

Cool. Thanks, bleen18. I'm sure I could cook something up with views using attachments and offsets, but then not sure how the pagination would work on that. Surprised that there isn't already a module to offer this in a more generic context (ie insert a block region after the nth teaser on the default front page, with views support).

Just FYI, there is a framework theme in Wordpress that has this functionality built in. It's called Thematic, has a widget area and setting in the GUI to permit you to insert that widget area after the nth teaser on the Wordpress index page. Just in case you wish to see this working in a different context for comparative purposes :)!

Have you tried panels

pazzypunk's picture

I think I've done what your talking about ... check out the top news list on http://www.sunjournal.com. Is that what you mean?

Basically I did that using views and panels.

Thanks for your reply!

RKopacz's picture

Thanks for the reply and the link. Yes, that is what I am trying to do! Cool, thanks for sharing this. If you don't mind, I'll take a peek at the code to see how you did it. However, the site I am building is a simple site, a "blog" in the traditional sense, and I was hoping to try to get that same effect by injecting something into the front page loop without adding the views/panels overhead to the site. Thought there might be a module that contributes this kind of functionality, or a code snippet for the template.php file.

It seems that if you can do it with Wordpress's index page loop, you should be able to do it with Drupal's default front page. May try to write a custom module if I can't find one, turn it into a contrib.

IMHO it would be easier to do

pazzypunk's picture

IMHO it would be easier to do it with views & panels then to write a custom module. :)

Views and Panels really aren't that much overhead. Create a new panel page, make it your site front page, and then have a view of the first x teasers, custom panel for ad tag, view of next y teasers (offset x teasers), rinse and repeat.

It might be possible to do it with a theme template override ... but I've never worked with that default /node view in Drupal, so I'm not sure.

Thanks I agree, but. . .

RKopacz's picture

I agree that it could be done that way, but one thing that I need to have is a pager at the bottom. Would your config work with a pager (say, three teasers, ad insert, three teasers with offset, and then a pager to repeat)? I just need to check it.

It seems as though there are some modules which come close to what I am looking to do, see content injector, but that injects content into every node on the default front page not into say, right after the third teaser on the default front page.

Thanks for your feedback :-)!

No module required

yelvington's picture

To generate a teaser list, Drupal invokes the node template repeatedly until the list is all printed out. All you need is a loop counter in the node-TYPE.tpl.php file and a bit of conditional code. When you look at the node template, notice how printing of the title is conditional.

Check this out

John Mark Maina's picture

https://drupal.org/project/ad Looks interesting enough. The only drawback is that for d7 you'll have to make due with the dev version.

1 CORINTHIANS 4:2 -  MOREOVER, IT IS [ESSENTIALLY] REQUIRED OF STEWARDS
THAT A MAN SHOULD BE FOUND FAITHFUL [PROVING HIMSELF WORTHY OF TRUST].
- AMPLIFIED BIBLE (AMP)

Advertising

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week