Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2008
    Location
    Boston
    Posts
    148
    Plugin Contributions
    0

    Default If/Else display Anchor Button

    Some of my products include a video clip at the bottom of the product description page. I'd like to add a button, 'See Video' that will anchor tag to the video at the bottom of the page. I would like the button to display near the top of the tpl_product_info_display . But ONLY be visible if a video exist on the page. The videos are embedded HTML Youtube videos. So maybe if($exists('embedded')) {
    then {


    Any ideas on the code needed to for this?

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,956
    Plugin Contributions
    96

    Default Re: If/Else display Anchor Button

    You could try the "Product Extra Files" plugin.

  3. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: If/Else display Anchor Button

    From the description for Product Extra Fields, it might be possible to use it, but sounds like overkill as you are not asking for downloadable files but embedded (Youtube?) videos. It still wouldn't give the conditional link without extra coding.
    Product Articles has optional handling features that could be used for this, but it would really work as well as anything to make a conditional that looks for the existence of a diagnostic string in the description in order to toggle the link. Something like
    PHP Code:
    if (strpos($products_description,'embed')) { //if the text embed does not appear in any descriptions but does appear in the embedding code
      
    echo '<a href="' zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('number_of_uploads')) ) . '#video' '"><img src="INSERT BUTTON IMAGE PATH HERE" />See video</a>';

    Refer to DrByte's explanation around post 11:
    http://www.zen-cart.com/showthread.p...rs-Not-Working
    Last edited by gjh42; 19 Mar 2013 at 06:55 AM.

  4. #4
    Join Date
    Apr 2008
    Location
    Boston
    Posts
    148
    Plugin Contributions
    0

    Default Re: If/Else display Anchor Button

    PERFECT
    Thank you!

    Added the code above from gjh to includes/templates/My_TEMPLATE/templates/tpl_product_info_display.php where I wanted the button to show and added an id for styling:

    Code:
    <!--bof product video -->
    <?php if (strpos($products_description,'embed')) { //if the text embed does not appear in any descriptions but does appear in the embedding code
     echo '<a href="' . zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('number_of_uploads')) ) . '#video' . '"><img id="video_button" src="http://keepsafeco.com/includes/templates/12497/buttons/english/watch-the-video-button.gif"></a>';
    }  
    ?>
    <!--eof product video -->

    Then, as gjh pointed out from DrBytes linked post, I just added
    Code:
    <a name="video">
    just above the embedded video in the product description through Admin/Catalog/Cat..Products

    Here's how it looks:
    Baby Gate

 

 

Similar Threads

  1. Quantity box - show if <10, else display msg
    By chabbu in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 11 Jun 2010, 01:11 PM
  2. How to Just display item/info and price on page, nothing else?
    By ghurty in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 14 May 2009, 04:15 AM
  3. if main display this else display this
    By poosk in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 21 Apr 2009, 02:04 PM
  4. Replies: 2
    Last Post: 3 Apr 2008, 01:21 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