Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2010
    Posts
    900
    Plugin Contributions
    0

    Default PHP Question: Adding href to Manufacturer image

    Hello,

    A while back I added my manufacturers' logos to product pages by inserting this code:

    <!--bof: Mfg logo image -->
    <?php
    if ($check_image = zen_get_products_manufacturers_image((int)$_GET['products_id'])) {
    echo '<a class="manufacturer">' . zen_image(DIR_WS_IMAGES . $check_image) . '</a>' . "\n" ;
    } else {
    echo ' ';
    }

    ?>

    <!--eof: Mfg logo image -->
    You can see it in action here:
    http://2staging.apswittcosalesDOTcom...12_oz._Aerosol

    Now I would now like to make that Techspray logo clickable, redirecting here:
    http://2staging.apswittcosalesDOTcom...acturers_id=31

    Here is an example of code that generates the href I want:
    <a href="' . DIR_WS_CATALOG . 'index.php?main_page=index&amp;manufacturers_id=' . $manufacturers->fields['manufacturers_id'] . '">';
    I just can't figure out how to wrap my image.

    Can someone help me, pretty please!

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: PHP Question: Adding href to Manufacturer image

    You could try this:
    Code:
    echo '<a class="manufacturer" href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $product_info->fields['manufacturers_id']) . '">' . zen_image(DIR_WS_IMAGES . $check_image) . '</a>' . "\n" ;
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Apr 2010
    Posts
    900
    Plugin Contributions
    0

    Default Re: PHP Question: Adding href to Manufacturer image

    Thanks, Ajeh!

    When I tried replacing the echo statement with yours, it breaks site:
    <?php
    if ($check_image = zen_get_products_manufacturers_image((int)$_GET['products_id'])) {
    echo '<a class="manufacturer" href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $product_info->fields['manufacturers_id']) . '">' . zen_image(DIR_WS_IMAGES . $check_image) . '</a>' . "\n" ;
    } else {
    echo ' ';
    }

    ?>
    When I tried replacing the entire statement just to see if it would work like this:
    <?php
    echo '<a class="manufacturer" href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $product_info->fields['manufacturers_id']) . '">' . zen_image(DIR_WS_IMAGES . $check_image) . '</a>' . "\n" ;

    ?>
    ...the logo gets replaced by my standard No_Image.jpg... but the link works!!!

    Getting close!

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: PHP Question: Adding href to Manufacturer image

    That IF makes the variable $check_image and if you remove the IF, then $check_image does not exist and it is part of what displays the image as that is the image ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Apr 2010
    Posts
    900
    Plugin Contributions
    0

    Default Re: PHP Question: Adding href to Manufacturer image

    So, this should have worked, right?
    <?php
    if ($check_image = zen_get_products_manufacturers_image((int)$_GET['products_id'])) {
    echo '<a class="manufacturer" href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $product_info->fields['manufacturers_id']) . '">' . zen_image(DIR_WS_IMAGES . $check_image) . '</a>' . "\n" ;
    } else {
    echo ' ';
    }

    ?>
    But it breaks the page

    What am I doing wrong? Is it that second $check_image?

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: PHP Question: Adding href to Manufacturer image

    This is what I have based on what you you originally posted but I just added another echo for giggles and grins:
    Code:
    <!--bof: Mfg logo image -->
    <?php
    echo '<br>Does this work below?' . '<br>';
    if ($check_image = zen_get_products_manufacturers_image((int)$_GET['products_id'])) {
    //echo '<a class="manufacturer">' . zen_image(DIR_WS_IMAGES . $check_image) . '</a>' . "\n" ;
    echo '<a class="manufacturer" href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $product_info->fields['manufacturers_id']) . '">' . zen_image(DIR_WS_IMAGES . $check_image) . '</a>' . "\n" ;
    } else {
    echo ' ';
    }
    ?>
    <!--eof: Mfg logo image -->
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  7. #7
    Join Date
    Apr 2010
    Posts
    900
    Plugin Contributions
    0

    Default Re: PHP Question: Adding href to Manufacturer image

    It works!!!! Yaaaaaay! Thank you, thank you, thank you!

    This is what is up now:
    <!--bof: Mfg logo image -->
    <?php
    if ($check_image = zen_get_products_manufacturers_image((int)$_GET['products_id'])) {
    echo '<a class="manufacturer" href="' . zen_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $product_info->fields['manufacturers_id']) . '">' . zen_image(DIR_WS_IMAGES . $check_image) . '</a>' . "\n" ;
    } else {
    echo ' ';
    }

    ?>

    <!--eof: Mfg logo image -->
    You rock!

  8. #8
    Join Date
    Apr 2010
    Posts
    900
    Plugin Contributions
    0

    Default Re: PHP Question: Adding href to Manufacturer image

    Quick follow on...

    Is there a way I can limit the width of my image to, say, no wider than 200px?

    I don't want to stretch an image that is smaller, just prevent it from being too wide.

    And...
    Can I auto tag the image with a description, say MFG_NAME + " catalog"?

    Thank you again for your awesome help!
    Last edited by Feznizzle; 27 Jan 2016 at 06:57 PM.

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: PHP Question: Adding href to Manufacturer image

    Coolness ... had me wondering for a bit there as I tested it originally in Zen Cart v1.5.4 and thought maybe there was something different in v1.5.1 and it wsa not picking up the manufacturers_id ... then I stuck it in v1.5.1 and it still worked ...

    Glad to hear that this was you and not me ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  10. #10
    Join Date
    Apr 2010
    Posts
    900
    Plugin Contributions
    0

    Default Re: PHP Question: Adding href to Manufacturer image

    Yeah, I have no idea what I did wrong. I followed your first instructions correctly, but it wonky for some reason. Second time I tried, worked like a charm!

 

 

Similar Threads

  1. adding manufacturer image to product page
    By gsdcypher in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 17 May 2009, 03:21 PM
  2. Adding href title value for prev / next...
    By modernm in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 28 Mar 2008, 09:20 PM
  3. Adding manufacturer image and desc
    By robmillion in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 31 Oct 2007, 02:19 AM

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