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

beckyjohnson’s picture

I saw that but I'm not sure what to do with it.

accessiveapps’s picture

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

beckyjohnson’s picture

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.

accessiveapps’s picture

have you tried to print out something like " hello world" in this tpl file? might not gotten picked up?

--patrick

beckyjohnson’s picture

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

avonleadesign’s picture

shouldn't it be page--front.tpl.php (note: two dashes)

awasson’s picture

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" />

beckyjohnson’s picture

I tired that too and it did not work.

awasson’s picture

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

beckyjohnson’s picture

Yeah, I have looked at the source. It doesn't even show up in the source..it's weird.

awasson’s picture

It looks like this?
<img width="929" height="137" border="0" alt="" src="/images/frontpage/slideshow_placeholder.jpg" />

beckyjohnson’s picture

No, I mean the image tag isn't even being put out. It's missing all together....

awasson’s picture

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

beckyjohnson’s picture

Maybe! ugh. Any ideas on what to do if that is the case?

awasson’s picture

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

bigdaddy1978’s picture

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

frikino’s picture

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!