By beckyjohnson on
On my zen sub theme, I am trying to print out an image that is in my theme folder, onto my front page.
In D6 I would do this:
<img width="929" height="137" border="0" alt="" src="<?php print base_path( )?><?php path_to_theme() ?>/images/frontpage/slideshow_placeholder.jpg" />
And it would work...This time, it's not. It's not grabbing the base path as far as I can tell. I end up seeing something that looks like themes/custom/nameofthing/image/image_name.jpg in the source code.
Adding .../ to make the tpl file look for the directory "images" outside of the tpl folder does not work.
Does anyone have any suggestions?
Rebecca
Comments
http://api.drupal.org/api/dru
http://api.drupal.org/api/drupal/includes--common.inc/function/base_path/7
http://api.drupal.org/api/drupal/includes--common.inc/function/base_path/7
:-)
Best
Patrick
http://rroarrr.com
--patrick
I saw that but I'm not sure
I saw that but I'm not sure what to do with it.
Is that the code you re
Is that the code you re using? if so you forgot a print where it say path_to_theme()
img width="929" height="137" border="0" alt="" src="<?php print base_path( )?><?php print path_to_theme() ?>/images/frontpage/slideshow_placeholder.jpg" />--patrick
I noticed that error and
I noticed that error and corrected it. I cleared my cache and then looked at my source code and it's not even been printed out in html on the page.
I don't understand what is up with this. I am using page-front.tpl.php and I am clearing my cache.....This is a zen subtheme...could this be a bug?
It's weird.
have you tried to print out
have you tried to print out something like " hello world" in this tpl file? might not gotten picked up?
--patrick
Yeah I just tried that. I get
Yeah I just tried that. I get nothing. It's weird.....it's just a sub theme of zen, and their pre-set up page-front.tpl.php
could be filename?
shouldn't it be page--front.tpl.php (note: two dashes)
Yes it still works just fine
I don't know if it's changed as far as getting the correct path to a sub-theme but in a simple theme I'm working on I have a Facebook icon and I am calling it with the following in my page.tpl.php file:
<img src="<?php print base_path() . path_to_theme(); ?>/images/facebook_off.png" alt="Facebook" width="24" height="34" class="myLink" />I tired that too and it did
I tired that too and it did not work.
What does the src in the html look like?
Have you looked at the HTML generated and looked at where it is trying to source the image from? That information will be helpful in troubleshooting this.
Andrew
Yeah, I have looked at the
Yeah, I have looked at the source. It doesn't even show up in the source..it's weird.
You mean...
It looks like this?
<img width="929" height="137" border="0" alt="" src="/images/frontpage/slideshow_placeholder.jpg" />No, I mean the image tag
No, I mean the image tag isn't even being put out. It's missing all together....
Then maybe the page.tpl.php file isn't being processed
Yeah, that's what I suspected... Maybe D7 isn't handling your sub theme the way you expect it to and it is ignoring page.tpl.php and instead falling back on Zen's page.tpl.php
Maybe! ugh. Any ideas on what
Maybe! ugh. Any ideas on what to do if that is the case?
Unfortunately I'm not an authority on sub-theming...
I create all of my themes from scratch for 5, 6 & (now) 7 so I'm not a great authority for sub-theming practices. It sounds like something is preventing you from being able to over-ride page.tpl.php but I haven't seen anything that really comes to mind here: http://drupal.org/node/225125
get base path
It doesn't say if this has been solved or not. But you seem to be missing a part of your code, specifically, you seem to be putting "path_to_theme" where it should be "drupal_get_path()" for example:
<img src="<?php print base_path() . drupal_get_path('theme', 'theme_name') . '/images/image.jpg'; ?>" alt="" />Hope this helps
Absolute url is best
Try like this :
<img alt="" src="<?php print $GLOBALS['base_url']."/".path_to_theme() ?>/gfx/le_sport_a_istres.jpg">Return for my exemple :
http://www.warskydesign.com/themes/omsistres/gfx/l-oms.jpg
work for all url patch :) this is ABSOLUTE url its why!