Forums / Templates, Stylesheets, Page Layout / Proper procedure for referencing images in overridden files?

Proper procedure for referencing images in overridden files?

Started by dsharp81 on 13 Jun 2011, 5:00 AM · Views: 806

Results 1 to 6 of 6
13 Jun 2011, 5:00 AM
#1
dsharp81 avatar

dsharp81

New Zenner

Join Date:
Jun 2011
Posts:
9
Plugin Contributions:
0

Proper procedure for referencing images in overridden files?

I am overriding the products page in my own template via:
/includes/templates/[TEMPLATE NAME]/templates/tpl_product_info_display.php

I want to include a link to another page on the site via an image of a gnome :D

I want to keep my file system clean in case someone else may have to edit this stuff later, I would like them to think that i did things correctly.

My question is how should i link to the image? If i store it in:
/includes/templates/[TEMPLATE NAME]/images

then put this in the html
<img src="/includes/templates/[TEMPLATE NAME]/images/gnome.gif" alt="Gnome" />
If they change the name of the template it will not show up properly, any suggestions or if you just think I am over thinking this would be great

13 Jun 2011, 5:06 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Proper procedure for referencing images in overridden files?

If they change the name of the template it will not show up properly
So do you want it to show with another template?

If so, the file & image should also go with the other template

Zen-Venom Get Bitten

13 Jun 2011, 5:46 AM
#3
dsharp81 avatar

dsharp81

New Zenner

Join Date:
Jun 2011
Posts:
9
Plugin Contributions:
0

Re: Proper procedure for referencing images in overridden files?

I just dont want it to stop working if I change the template name, for example if I start a new site and want to use my same layout.

13 Jun 2011, 6:02 AM
#4
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Proper procedure for referencing images in overridden files?

Use Zen Cart default code:

<?php echo zen_image(DIR_WS_TEMPLATES . $template_dir . '/images/**image_name.gif**','**alt text for image**'); ?>

Change the parts in Bold to match your needs.

The above looks for images based on the current Template being used. Make sure though, you have the image available if/when you change Templates.

Also, do not start a path with a forward slash.

/includes << bad

includes << good

You will find things work better. :smile:

The learning is in the doing.

Potent Products

13 Jun 2011, 10:39 AM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Proper procedure for referencing images in overridden files?

I just dont want it to stop working if I change the template name, for example if I start a new site and want to use my same layout.
You will have to pull/copy your template specific modified files to any new template you create

Zen-Venom Get Bitten

21 Jun 2011, 6:28 AM
#6
dsharp81 avatar

dsharp81

New Zenner

Join Date:
Jun 2011
Posts:
9
Plugin Contributions:
0

Re: Proper procedure for referencing images in overridden files?

Website Rob:

Use Zen Cart default code:

<?php echo zen_image(DIR_WS_TEMPLATES . $template_dir . '/images/**image_name.gif**','**alt text for image**'); ?>

This is exactly what i was looking for this should work perfectly :smile: