Hello,
In my site project, I wish to have an image in page background which displays according to every contents (a node = a background-image).
This image will be stretchable by a script according the size of the browser. I have to insert it into the code, just before the tag <body>.
I created a image field in the type of contents (Drupal 7) to insert according to the node one specific image there.
But how may I make so that this field displays only in this place and not in the "$page[‘content’]" of "page.tpl.php" for example ?
What do I have to according to you integrate as variable ? It takes place well in the "page.tpl.php" or html.tpl.php" ? With views ? Or...
Am I clear ? I'm sorry, I'm french :/
Thanks a lot.
Comments
If you want it directly after
If you want it directly after the opening
<body>tag then you want to put it in html.tpl.php. You can use hook_preprocess_html in your theme's template.php file to set up the extra variable.In template.php
Then in html.tpl.php:
Hope that helps
Thanks a lot for your
Thanks a lot for your response. I'll try this evening. I'm in my office ;)
But just a question : where is defined "$my_image" ?
Thx !
When you add it to the $vars
When you add it to the $vars array in the preprocess function Drupal transfers it through to your template file as a variable, I imagine using extract() or some such.
I try your proposition, but
I try your proposition, but doesn't work... $my_image was not defined...
But I try this and it works fine ;)
There isn't preprocess function in template.php... I try to do this.
Thanks iSOS !
Still trying on my end.
That worked for me too.