Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / If/Else display Anchor Button

If/Else display Anchor Button

Views: 1,256

Results 1 to 4 of 4
19 Mar 2013, 1:06 AM
#1
mickmo68 avatar

mickmo68

Zen Follower

Join Date:
Apr 2008
Location:
Boston
Posts:
129
Plugin Contributions:
0

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?

19 Mar 2013, 2:29 AM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,080
Plugin Contributions:
56

Re: If/Else display Anchor Button

You could try the "Product Extra Files" plugin.

19 Mar 2013, 5:50 AM
#3
gjh42 avatar

gjh42

Black Belt

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

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
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>';
}

<http://www.zen-cart.com/showthread.php?149636-Named-Anchors-Not-Working>
19 Mar 2013, 4:16 PM
#4
mickmo68 avatar

mickmo68

Zen Follower

Join Date:
Apr 2008
Location:
Boston
Posts:
129
Plugin Contributions:
0

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:

<!--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 ```
<a name="video">


Here's how it looks:
[Baby Gate](http://keepsafeco.com/baby-safety-gates/playpens/indoor-and-outdoor-playpen---colorplay-superyard?cPath=29_37)