This must have been asked somewhere, but after searching for about 20 minutes I can't find anything. How can I put an ad after the first node on my homepage? I know there's a loop, but I can't figure out how to set a variable outside node.tpl.php so I can increment the loop.

This is what I'd like to do:
if ($postnum == $showads) {

ad here.

} $postnum++;

It's not working because setting $postnum and $showads in page.tpl.php doesn't allow node.tpl.php to see them.

Thanks,
Marcus

http://cmsfactor.com
http://enrichr.com

Comments

reganjcunliffe’s picture

I am wanting to place an ad in a right aligned div in the first story on the homepage but at the moment it comes up every single time.

reganjcunliffe’s picture

if ($seqid == 1):

[ad code here]

endif;

If you're using 4.7 then I think you need to change the $seqid to $id

cheers

After much trial and error on my American Idol site, here is my working ad post