Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / What is the variable for the template directory?

What is the variable for the template directory?

Locked

Views: 2,770

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
5 Apr 2007, 11:30 AM
#1
paul3648 avatar

paul3648

Zen Follower

Join Date:
Mar 2007
Location:
Taiwan
Posts:
239
Plugin Contributions:
0

What is the variable for the template directory?

I want to use rollover images for the horizontal menu bar.

This code works:

<li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '" onMouseover="MyLink1.src=\'includes/templates/menu-home-on.png\';" onMouseOut="MyLink1.src=\'includes/templates/menu-home-off.png\';">'; ?><img id="MyLink1" src="includes/templates/menu-home-off.png"></a></li>
...but I would prefer to use a variable so that the images could be stored in the working template folder and that this code could be used for other templates without changing the code.

So - is there a simple variable I can drop in there that points to the MY_TEMPLATE directory?

5 Apr 2007, 12:51 PM
#2
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: What is the variable for the template directory?

' . zen_image($template->get_template_dir(YOUR IMAGE DEFINE HERE, DIR_WS_TEMPLATE, $current_page_base,'images'). '
6 Apr 2007, 3:08 AM
#3
paul3648 avatar

paul3648

Zen Follower

Join Date:
Mar 2007
Location:
Taiwan
Posts:
239
Plugin Contributions:
0

Re: What is the variable for the template directory?

Thanks for this, but I can't get it to work inside 'onMouseover'

I wish there was just simple variable that I could use for the template directory itself, like DIR_WS_TEMPLATE - but I guess not...

6 Apr 2007, 9:22 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: What is the variable for the template directory?

You just follow the pattern:

<li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '" onMouseover="MyLink1.src=\'' . zen_image($template->get_template_dir( 'menu-home-on.png', DIR_WS_TEMPLATE, $current_page_base, 'images') . '/menu-home-on.png\'" onMouseOut="MyLink1.src=\'' . zen_image($template->get_template_dir( 'menu-home-off.png', DIR_WS_TEMPLATE, $current_page_base, 'images') . '/menu-home-off.png\'"> <img id="MyLink1" src="' . zen_image($template->get_template_dir( 'menu-home-off.png', DIR_WS_TEMPLATE, $current_page_base, 'images') . '/menu-home-off.png'; ?>">
</a></li>

Using this approach allows it to check for the override image for each image, not just a check to see which template is active. That way if the image is missing, it can fall back to the default.

7 Apr 2007, 5:37 AM
#5
paul3648 avatar

paul3648

Zen Follower

Join Date:
Mar 2007
Location:
Taiwan
Posts:
239
Plugin Contributions:
0

Re: What is the variable for the template directory?

That code gave me an error.

I'm finally using the following code and it seems to work:

<li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '" onMouseover="MyLink1.src=\'' . zen_output_string($template->get_template_dir('menu-home-on.png', DIR_WS_TEMPLATE, $current_page_base, 'buttons/' . $_SESSION['language'] . '/') . 'menu-home-on.png') . '\';" onMouseout="MyLink1.src=\'' . zen_output_string($template->get_template_dir('menu-home-off.png', DIR_WS_TEMPLATE, $current_page_base, 'buttons/' . $_SESSION['language'] . '/') . 'menu-home-off.png') . '\';"><img id="MyLink1" src="' . zen_output_string($template->get_template_dir('menu-home-off.png', DIR_WS_TEMPLATE, $current_page_base, 'buttons/' . $_SESSION['language'] . '/') . 'menu-home-off.png') . '"'?></a></li>