Zen Cart Logo
Forums / General Questions / Edit php to make specific product title an image

Edit php to make specific product title an image

Views: 1,604

Results 1 to 9 of 9
22 Nov 2011, 7:26 PM
#1
danwebman avatar

danwebman

New Zenner

Join Date:
Nov 2008
Posts:
71
Plugin Contributions:
0

Edit php to make specific product title an image

Hi, using 1.39h and will try and keep it as simple as possible because I think I am close?
I have tried the Images for Titles add-on too, and it doesn't work for this specifically. But I am trying to take a little of that and apply it to a specific place in my php to call an image instead of the Product Title-->
The Page example:
http://www.paynemason.com/Showcase/products/index.php?main_page=index&cPath=2_7

**Where it says "Black Lion Robusto Primier" in Grey, to the right of the product image - only in this spot - is where I want to place an image. Not anywhere else the Product Name or _id is called in to show "Black Lion Robusto Primier" . I only want to change the the title to an image where it is listed under it's category.

Here is the hack/image call from the Add-on Image for Title modification to tpl_product_info_display.php

<!--bof Product Name--> <h1 id="productName" class="productGeneral"><?php echo title_image_exists($products_name, 'prodname' . $_GET['products_id']); ?></h1> <!--eof Product Name-->

So I figured to find and switch out id="itemTitle" (* id I'm getting with firebug where these product titles I want changed are) with id=productName. Problem I'm having is putting this in the right spot in the following php page:

/includes/templates/template_default/common/product_listing.php
and
/includes/modules/product_listing.php

--because these are the only two pages calling for "itemTitle" like this:
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'manufacturers_id=' . $_GET['manufacturers_id'] . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div>
and

$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">

or this one in includes/modules/product_listing
'<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ?

so I tried to put that code from the product_info_display edit to the product_listing page but can't seem to get it. Anybody done this or have a different way of looking at it?

Thanks!

22 Nov 2011, 7:39 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Edit php to make specific product title an image

danwebman:

I have tried the Images for Titles add-on too, and it doesn't work for this specifically.
How exactly does it not work?
What specifically does it do differently than what you are expecting?

22 Nov 2011, 8:41 PM
#3
danwebman avatar

danwebman

New Zenner

Join Date:
Nov 2008
Posts:
71
Plugin Contributions:
0

Re: Edit php to make specific product title an image

Hi. It changes up the Title on the product info page, but not the page I showed in the link. I don't want any changes to the product info page- I only want to edit in an image for the product title on this specific page. The page where it is a listing of all the products in that category.

22 Nov 2011, 8:50 PM
#4
danwebman avatar

danwebman

New Zenner

Join Date:
Nov 2008
Posts:
71
Plugin Contributions:
0

Re: Edit php to make specific product title an image

acctually, what would give me the easest help for you is to just let me know what page to edit- which .php am I looking for that displays the page I am looking to edit? Then I will at least know I am testing the right part. Thanks!

22 Nov 2011, 8:59 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Edit php to make specific product title an image

Yes, you are correct: Images for Titles is not currently configured to handle product names in the product listing page.
It is a simple matter to extend the functionality, however.

First, there is no /includes/templates/template_default/common/product_listing.php.
Perhaps you are thinking of /includes/templates/template_default/templates/tpl_modules_product_listing.php?
Also, /includes/modules/product_listing.php is a core file; if you want to modify it, copy it to /includes/modules/your_template/product_listing.php.

title_image_exists($products_name, 'prodname' . $_GET['products_id'])

can be adapted to the product listing as

title_image_exists($listing->fields['products_name'], 'prodlistname' . $listing->fields['products_id'])

This can be substituted for
$listing->fields['products_name']
in product_listing.php for the product name item case (be sure you are working on the list set of cases and not the heading set).

Name your images like prodlistname23.gif.

23 Nov 2011, 2:11 AM
#6
danwebman avatar

danwebman

New Zenner

Join Date:
Nov 2008
Posts:
71
Plugin Contributions:
0

Re: Edit php to make specific product title an image

Intresting, so I did it(replace $listing->fields['products_name'] with the code you showed me) and the listing page still works, So I'm pretty sure the code is going in there solid, but the image isn't showing. named prodlist64.png for product id #64 and nothing. Still the text. Am I maybe putting the image in the wrong spot. Put it in images folder and buttons folder?

23 Nov 2011, 2:13 AM
#7
danwebman avatar

danwebman

New Zenner

Join Date:
Nov 2008
Posts:
71
Plugin Contributions:
0

Re: Edit php to make specific product title an image

To add, I went with:
case 'PRODUCT_LIST_NAME':
$lc_align = '';
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . title_image_exists($listing->fields['products_name'], 'prodlistname' . $listing->fields['products_id']) . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
break;

inthe modules/product_listing.php

23 Nov 2011, 2:34 AM
#8
drbyte avatar

drbyte

Sensei

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

Re: Edit php to make specific product title an image

danwebman:

the image isn't showing. named prodlist64.png for product id #64 and nothing. Still the text.
Why are you using .png ? And why aren't you using "prodlistname" as the prefix?
Glenn said:
gjh42:

Name your images like prodlistname23.gif.
And the documentation for the mod says > Name your product-name images like prodname69.gif, and save in /your_template/buttons/your_language/. Replace the number with the product id

23 Nov 2011, 3:05 AM
#9
danwebman avatar

danwebman

New Zenner

Join Date:
Nov 2008
Posts:
71
Plugin Contributions:
0

Re: Edit php to make specific product title an image

Using .png for the quality w/transparency. Edited the .php to include .png's in the modified files from Images for Titles.

Accidentally wrote ##########= really had images named- prodlistname64.png and prodlistname64.gif in that buttons folder behind my template_default.... duh! Thanks for all the help!! I made a new buttons/english/prodlistnameXX.png uploaded and pow, looks great :)