By zsiswick on
Is there a best practice for including an html file containing image source tags directly in the page.tpl.php file or is that typically frowned upon? I'm trying to embed a custom navigation banner at the top of my theme and haven't found any modules or blocks that would allow me to accomplish this. Some expert advice would be much appreciated.
Thanks!
Comments
You can use an existing
You can use an existing theme and modify it.
On page.tpl.php you can create a div or a table in which your menu goes.
Class for them can be defined at style.css in that folder.
Images can be passed through theme function or can be directly coded in page.tpl.php file.
Hope this will help
Cheers.
I am looking into adding
I am looking into adding static images to my page.tpl.php document, and I am confused as to where this page looks for images. I tried just
but it would not display the images. I am using a modified zen theme, on drupal 5.7. Where should the images go, and how should the path be defined, so that I can add static images onto my drupal template?
-Thanks
One approach...
Let's say your theme lives in sites/all/themes/my-cool_theme, and you have a subdirectory images in there to hold your static images. Now say you have a file called banner.jpg in this subdirectory, the path so far would look like:
To get Drupal to find this, we need to add some PHP that calls a Drupal function and builds the image path up..
Here's a fragment of code that could be pasted into your page.tpl.php (with the theme, subdir & filename changed to your own):
As you can see, a second fragment of PHP inside the <IMG> tag outputs the path. Also note how we don't provide any path details to the top-level of the theme, just any sub-dirs - the path_to_theme() takes care of that.
Thanks, I got to try it out
Thanks, I got to try it out this morning, and it worked just like I wanted.
-Sam
I did <div
I did
and that works fine for the front page, forum page, blog page, etc. But the directory breaks on any of the node pages. If I look for the image path on the front page I see,
http://localhost/drupal-5.7/themes/zen/images/contact_us.jpg
But on the node pages the image path becomes,
http://localhost/drupal-5.7/node/themes/zen/images/contact_us.jpg
I am running drupal 5.7 with a modified zen theme. And my images are located in htdocs\drupal-5.7\themes\zen\images. The code I posted previously is in
drupal-5.7\themes\zen\page.tpl.php
Any help would be appreciated.
Does anyone know how to use
Does anyone know how to use a php variable to always get to sites/all/themes/...
the path_to_theme works on page.tpl.php but it does not work on page-front.tpl.php or any other templates.
For example on the front page, the image path changes to drupal-6.2/front/sites/all/themes/...
when I use the path_to_theme to create a variable.
Anyone?
$directory
Try using the $directory variable.
______________________________________________________________________________________________________
mybesinformatik.com - Drupal website development
______________________________________________________________________________________________________
This should work.
<img src ="<?php print base_path().path_to_theme(); ?>/images/XXX.jpg" />Thanks
I'm not sure why this didn't attach to your message the first time. But I wanted to let people know that your solution works.
didn't work for me
it didn't seem to work for me...
i did exactly the same thing...
i also tried to hardcoding the path, but no luck :(
any thoughts would be appreciated...
thanks in advance
Thanks
Worked like a charm.
Thank you Thankyou
Thanks for this post and answers. I've been scratching my head at this one all day.