Clickable top banner

pruser - September 9, 2008 - 01:02

I'm trying to make top image banner on web page clickable/referer.
I put this code into page.tpl.php in my themes folder: <a href="/sk/" > <img src="./sites/all/themes/darsch/img/header13.gif" alt="home" width="960" height="265"></a>
but it gives me a problems: it doesn't work on all pages and for anonymous user - only when i'm logged in and also different browsers gives different results.
before there was a div with css property background image but it wasn't clickable/refering.

what's may be the best way to make it work? Is it bad idea to put html code into php generated page?

thanks

site with the problems: http://testonly.rachot.sk/sk/

Remove the dot at the front

nevets - September 9, 2008 - 03:20

Remove the dot at the front of the path so './sites/...' becomes '/sites/...'

dot

pruser - September 9, 2008 - 03:32

i had it without a dot and it didn't work either. but i removed it anyway

So what does not work mean?

nevets - September 9, 2008 - 03:40

So what does not work mean?

if you follow the link you

pruser - September 10, 2008 - 16:58

if you follow the link you can see that it works only on two pages out of seven.

It has to do with your

nevets - September 10, 2008 - 23:11

It has to do with your themes page.tpl.php, it is generating different html based on something. In the case where the link does not work the image comes from a header div.

check now:

pruser - September 12, 2008 - 02:31

check now: http://testonly.rachot.sk/sk/

it works here, i had to put complete path, not just relative path: <a href="/sk/"> <img src="http://testonly.rachot.sk/sk/sites/pathtothemefolder/img/header13.gif" alt="podvod" width="960" height="265"></a>

i don't think its 100% secure but it works. probably should go to php function or something.

Use $base_path & $directory

Alan D. - September 12, 2008 - 12:44

If you are working with a template based on the phptemplate engine, use <?php print $base_path . $directory; ?> for all links, this will work when you are running from a sub-folder or a sub-domain.

The function calls are base_path() and path_to_theme(), just in case the above variables are out of scope.

Eg:

<a href="<?php print base_path(); ?>"> <img src="<?php print base_path() . path_to_theme(); ?>/img/header13.gif" alt="podvod" width="960" height="265"></a>

Alan Davison
www.caignwebs.com.au

 
 

Drupal is a registered trademark of Dries Buytaert.