Zen Cart Logo
Forums / General Questions / Manufacturers URL

Manufacturers URL

Locked

Views: 1,773

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
20 Jan 2010, 6:29 PM
#1
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Manufacturers URL

I can't help feeling this should be easy even for someone as inexperienced in php as I am but I just can't work out how to do it :frusty:

I have the manufacturer name showing on my product info page but I'd like to turn this in to a link to the manufacturers home page.
I've aleady added the URL in the manufacturer maintenance screen in admin.

Can anyone tell me the code to retrieve the manufacturer url?
I've found the function 'zen_get_manufacturer_url' which needs the manufacturer ID and language ID as parameters but I'm not sure they are available on the product info page?

Is there an easy way to retrieve the URL or do I need to read it from the database with SQL?

Thanks for your help guys!!!!

21 Jan 2010, 6:13 PM
#2
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: Manufacturers URL

Ok, I've managed to do it :clap:.....It took me a while to figure it all out so for anyone else who wants to retrieve the manufacturers URl here's what you do.................

First, you need to add the following function to the end of /includes/functions/functions_lookups.php, just before the last '?>'

////
// Return the manufacturers URL in the needed language
// TABLES: manufacturers_info
function zen_get_manufacturer_url($manufacturer_id, $language_id) {
global $db;

$manufacturer = $db->Execute("select manufacturers_url
                              from " . TABLE_MANUFACTURERS_INFO . "
                              where manufacturers_id = '" . (int)$manufacturer_id . "'
                              and languages_id = '" . (int)$language_id . "'");

return $manufacturer->fields['manufacturers_url'];

}

Now you need to call the function from your product info page, which is file /templates/YOURTEMPLATE/templates/tpl_product_info_display.php

Find the code:

<?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n"; ?>

and replace it with:

<?php $manufacturers_url = zen_get_manufacturer_url(zen_get_products_manufacturers_id($products_id_current),$_SESSION['languages_id']); echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name) and empty($manufacturers_url)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '<li>' . sprintf(TEXT_PRODUCT_MANUFACTURER . '<a href="%s" target="_blank">' . $manufacturers_name . '</a>', zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($manufacturers_url), 'NONSSL', true, false)) . '</li>') . "\n"; ?>

and you're done!

22 Jan 2010, 5:31 AM
#3
amirgtr avatar

amirgtr

New Zenner

Join Date:
Mar 2009
Posts:
45
Plugin Contributions:
0

Re: Manufacturers URL

Wow, nice work dude! And thanks a ton for sharing.

One thing though. Your code keeps adding http:// to the beginning of the URL. My URLs already have that, so it messes things up. How do I get rid of it?

22 Jan 2010, 5:48 AM
#4
amirgtr avatar

amirgtr

New Zenner

Join Date:
Mar 2009
Posts:
45
Plugin Contributions:
0

Re: Manufacturers URL

Yup, got it.

  
//Display Manufacturer name  
<?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . '<b>' . TEXT_PRODUCT_MANUFACTURER . '</b>' . $manufacturers_name . '</li>' : '') . "\n"; ?>
 

//Display Manufacturer URL
  <?php
$manufacturers_url = zen_get_manufacturer_url(zen_get_products_manufacturers_id($products_id_current) ,$_SESSION['languages_id']);

echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name) and empty($manufacturers_url)) ? '' . '' : '<li>' . sprintf('<b>Manufacturer URL: </b>' . '<a href="' . $manufacturers_url . '" target="_blank">' .

$manufacturers_url . '</a>', zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($manufacturers_url), 'NONSSL', true, false)) .

'</li>') . "\n";

?>

Basically just took out the %s and put $manufacturer_url in there. Just sharing so in case anybody is wondering.

22 Jan 2010, 5:59 AM
#5
amirgtr avatar

amirgtr

New Zenner

Join Date:
Mar 2009
Posts:
45
Plugin Contributions:
0

Re: Manufacturers URL

This 7 minuter editing this is really getting on my nerves.

  <?php //Display Manufacturer name
echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . '<b>' . TEXT_PRODUCT_MANUFACTURER . '</b>' . $manufacturers_name . '</li>' : '') . "\n"; ?>
  
  <?php //Display Manufacturer URL
$manufacturers_url = zen_get_manufacturer_url(zen_get_products_manufacturers_id($products_id_current) ,$_SESSION['languages_id']);

echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name) and empty($manufacturers_url)) ? '' . '' : '<li>' . sprintf('<b>Manufacturer URL: </b>' . '<a href="' . $manufacturers_url . '" target="_blank">' .

$manufacturers_url . '</a>', zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($manufacturers_url), 'NONSSL', true, false)) .

'</li>') . "\n";

?>
22 Jan 2010, 12:50 PM
#6
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: Manufacturers URL

ah, yeah I forgot about the http prefix!

Thanks for fixing it:bigups: