Results 1 to 6 of 6
  1. #1

    help question 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

    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!!!!

  2. #2

    Default Re: Manufacturers URL

    Ok, I've managed to do it .....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!

  3. #3
    Join Date
    Mar 2009
    Posts
    45
    Plugin Contributions
    0

    Default 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?

  4. #4
    Join Date
    Mar 2009
    Posts
    45
    Plugin Contributions
    0

    Default Re: Manufacturers URL

    Yup, got it.

    PHP Code:
    //Display Manufacturer name  
    <?php echo (($flag_show_product_info_manufacturer == 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 == 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'truefalse)) .

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

    ?>
    Basically just took out the %s and put $manufacturer_url in there. Just sharing so in case anybody is wondering.
    Last edited by AmirGTR; 22 Jan 2010 at 06:55 AM.

  5. #5
    Join Date
    Mar 2009
    Posts
    45
    Plugin Contributions
    0

    Default Re: Manufacturers URL

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

    PHP Code:
      <?php //Display Manufacturer name
    echo (($flag_show_product_info_manufacturer == 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 == 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'truefalse)) .

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

    ?>

  6. #6

    Default Re: Manufacturers URL

    ah, yeah I forgot about the http prefix!

    Thanks for fixing it

 

 

Similar Threads

  1. How to add manufacturers url to the manufacturers image
    By suedouglas in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 27 Jan 2016, 04:19 PM
  2. Manufacturers URL doesn't update!?!
    By Alex Clarke in forum General Questions
    Replies: 7
    Last Post: 7 Dec 2007, 06:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR