Display something after first node on frontpage

formicin - September 13, 2006 - 05:28

I would like to add a block or show a banner after the first node on the front page, but I couldn't create some kind of count for nodes.

My front page should look like:

Title of the first node
The contents of first node.. bla bla bla

>Banner here<

Title of the second node
The contents of second node.. bla bla bla

Title of the third node
The contents of third node.. bla bla bla

How can I achive this?

...

mooffie - September 13, 2006 - 06:33

A quick solution is to append the following to 'node.tpl.php':

<?php
if ($id == 1 && $is_front) {
  print
"...banner here...";
}
?>

'id' is a counter variable managed by the phptemplate engine.

(but, theoretically, there exist some cases when the above won't really work, e.g. when some non-cacheable filter in your first node calls node_view thus incrementing this counter.)

I'm not only using

formicin - September 13, 2006 - 06:50

I'm not only using node.tpl.php, but also using another node-blabla.tpl.php files. So I think I need something else.

Edit: I applied this code to all my node-blabla.tpl.php files and it works like a charm:)
Thank you very much!

onkare.com

 
 

Drupal is a registered trademark of Dries Buytaert.