Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By zzzmarcus on
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
Comments
similar for me
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.
answer =
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