Forums / Templates, Stylesheets, Page Layout / replace product name text with images - possible??

replace product name text with images - possible??

Locked

Views: 1,589

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
7 Oct 2006, 5:37 PM
#1
matt_noiseux avatar

matt_noiseux

New Zenner

Join Date:
Sep 2006
Posts:
19
Plugin Contributions:
0

replace product name text with images - possible??

Since the product names are used to populate the breadcrumbs, header and sideboxes I have a feeling the short answer is 'no'. But I was just wondering if anyone has developed a way to insert images for the product and page titles.

I had thought that maybe I could set the text in the css to be the same as my background color (so it would appear invisible) but then not sure how I would go ahead and insert my image url's.

Any advice or thoughts would be appreciated. I may just turn this into a pet project. Would be great if the admin area let you specify an image that would override title text.

7 Oct 2006, 6:08 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: replace product name text with images - possible??

That functionality is not built-in, but you could customize your templates to produce it.

Since you didn't talk about which pages you wanted this for, it's hard to give you any specifics.

However, here's a start, assuming you're talking about the product-info page.

(remember, this affects content which normally appears inside H1 tags, which are important for SEO benefits ... so, you may want to rethink things slightly ... food for thought)

If you look at your tpl_product_info_display.php template file, you'll see a section that looks like this:

<!--bof Product Name-->
<h1 id="productName" class="productGeneral"><?php echo $products_name; ?></h1>
<!--eof Product Name-->
```Note the reference to $products_name

Normally the $products_name variable is set to be the product name contained in the database.

To override what normally appears in place of $products_name, go to:
/includes/modules/pages/product_info/main_template_vars_product_type.php

If you add code, as shown below, to this file, you'll be able to use the product image setting to locate a matching image for the product name instead:```
// Nothing special to do here for primary product_info type
```replaced by:```
  $title_image_suffix = '_TITLE';
  if ($products_image != PRODUCTS_IMAGE_NO_IMAGE && $products_image != '') {
    $products_image_extension = substr($products_image, strrpos($products_image, '.'));
    $products_image_base = str_replace($products_image_extension, '', $products_image);
    $new_title_image = $products_image_base . $title_image_suffix . $products_image_extension;
		if (file_exists($new_title_image)) $products_name = zen_image($new_title_image);
	}

Using this, if you have /images/t44yellow.jpg as your primary product image, then you can create another file called /images/t44yellow_TITLE.jpg (yes, literal _TITLE) for the title to display instead of the name.

If you don't like _TITLE, then choose another suffix and enter it in the code above, and name your images accordingly.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

9 Oct 2006, 6:22 PM
#3
matt_noiseux avatar

matt_noiseux

New Zenner

Join Date:
Sep 2006
Posts:
19
Plugin Contributions:
0

Re: replace product name text with images - possible??

Ah Ha! I had a feeling that someone would already have it covered. And in a much better way than I would have been able to figure out. I will give it a try!

I am curious t oknow wbout SEO benefits, though, it is a term I am not familiar with. Looks like I have some homework - thanks again for the advice.

Matt

10 Oct 2006, 2:36 AM
#4
matt_noiseux avatar

matt_noiseux

New Zenner

Join Date:
Sep 2006
Posts:
19
Plugin Contributions:
0

Re: replace product name text with images - possible??

One thing that I just thought of - this code may not work for User Defined Pages and EZ Pages - they do not have photos set up in the same way that products do. Any advice there? I am wondering if I could somehow have images that correspond to the title and then override the title if present? Let me know if you have any ideas...

11 Oct 2006, 5:48 AM
#5
drbyte avatar

drbyte

Sensei

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

Re: replace product name text with images - possible??

You have H1 tags in all your templates. You'll have to replace all those with an image instead.

Again, search engines will not find the data for the all-important H1 tag if you don't have any text in it. Thus your search-engine-rankings may suffer as a result.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.