Forums / All Other Contributions/Addons / YouTube in Product Descriptions

YouTube in Product Descriptions

Views: 2,050

Results 1 to 16 of 16
26 Oct 2011, 4:26 PM
#1
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

YouTube in Product Descriptions

Thought this might help some people. It is a little mini-module that lets you add youtube videos to your product descriptions. A thumbnail of the video will be inserted. Once clicked the video is played in a lightbox type window, which is quite nice.

Videos can be added to the product description using a bit of text like this:

ADlAc-NsDng

where "ADlAc-NsDng" is the youtube identifier for the video.

It really is provided 'as is' but if a few people test it, and maybe even write some proper instructions, then it might be of use to someone. Who knows....

Nick
iszent.com

9 Dec 2011, 12:24 AM
#3
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: YouTube in Product Descriptions

Hi Nick, got this installed but can't get it to work. Any ideas?

When I click on the video it just defaults to the shop homepage.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

9 Dec 2011, 10:58 AM
#4
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: YouTube in Product Descriptions

Hi Nick,
Are you on a development server or can I look at the page?
Nick

Nick
iszent.com

9 Dec 2011, 11:19 AM
#5
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: YouTube in Product Descriptions

Hi Nick, no its not on a development server. I took it off the website for now but can show you what is happening if you give me ten minutes.

Hang fire and I'll message you back in a moment.

Nick

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

9 Dec 2011, 11:39 AM
#6
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: YouTube in Product Descriptions

Right first things first

Go here

http://www.aqua-fun.co.uk/index.php?main_page=index&cPath=3&sort=20a&page=6

And find the product in the listing called Waboba Ball

You will see that the you tube shortcode appears in the product listing so it appears like this

qSWmAzpUlts

under the listing description

Next issue

Go here

http://www.aqua-fun.co.uk/index.php?main_page=product_info&cPath=3&products_id=92

Don't click on 'View Waboba Ball Videos here!' as that will take you to a page of all the videos on the site.

Click on the thumbnail created by zentube and you will see it takes you to the homepage and puts a # in the URL.

Cheers

Nick

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

9 Dec 2011, 1:23 PM
#7
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: YouTube in Product Descriptions

OK .

Product Listing.
Yeah, you will probably need to strip it out of the product listing description because it won't work there and just looks a mess. Yes, the site it was built for didn't use descriptions in the product listing so I never thought of this. So you'd need to do a bit of php in product_listing.php to strip out everything between the tags

Second problem
Well you are loading jQuery and the scripts in the wrong order. I think this is partly due to my bad instructions in the install notes but you need to ensure that jQuery is loaded before the scripts for zentube.

Nick
iszent.com

9 Dec 2011, 7:12 PM
#8
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: YouTube in Product Descriptions

You are looking for something like this in product_listing.php

        $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';

and change it for something like :

$temp_desc =  zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
$id = Getbetween($temp_desc,'','');
$get_rid_of =''.$id.'';
$temp_desc = str_replace($get_rid_of,'',$temp_desc);


        $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' .$temp_desc. '</div>';

completely untested but you can give it a go.

Nick
iszent.com

10 Dec 2011, 1:14 AM
#9
gjh42 avatar

gjh42

Black Belt

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

Re: YouTube in Product Descriptions

How about this:

$temp_desc = preg_replace('!*!','',$temp_desc);

preg_replace() will handle any number of pairs of [video] tags plus content rather than just one.

10 Dec 2011, 10:25 AM
#10
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: YouTube in Product Descriptions

Glenn is right. That would work better. What I'd go for is:

$temp_desc = preg_replace('!*!','',zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']));  

$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id'] > 0) ?  zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_id']))) . '&products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes($temp_desc)), PRODUCT_LIST_DESCRIPTION) . '</div>';

Which does the preg_replace earlier so the length of the final string won't be altered by the preg_replace.

Nick
iszent.com

13 Dec 2011, 7:22 AM
#11
oregongardener avatar

oregongardener

New Zenner

Join Date:
Jul 2011
Location:
Oregon
Posts:
16
Plugin Contributions:
0

Re: YouTube in Product Descriptions

This was intriguing ... and confusing, at the same time.
I have several items where I'm using YouTube videos in the product description and never thought it was an issue until reading these posts.

What I use is like this:

<iframe height="300" frameborder="0" width="480" title="YouTube video player" src="http://www.youtube.com/embed/ucL6DSl3f80?rel=0">&amp;amp;amp;nbsp;</iframe>

Mine works, but yours must do something I'm missing or you wouldn't have gone to the trouble to write the code. :blush:

So, can you tell me what I'm missing?

13 Dec 2011, 9:40 AM
#12
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: YouTube in Product Descriptions

@oregongardener
not at all. if it works it works. All mine does really is
-- puts a thumbnail rather than the whole video
-- plays the video in a lightbox type pop-up when the thumbnail is clicked
-- lets my client add videos in an easier way without having to think about the code
that's all.

Nick
iszent.com

14 Dec 2011, 3:18 AM
#13
oregongardener avatar

oregongardener

New Zenner

Join Date:
Jul 2011
Location:
Oregon
Posts:
16
Plugin Contributions:
0

Re: YouTube in Product Descriptions

Ah, okay - sounds good. I was wondering as there are times when Zen Cart balks at the iframe code and refuses to display the 'update' buttons on the second screen (or ANY buttons).
Backing up and trying again will get it working, but I figured that might have been the impetus for your efforts. :D
Appreciate the response!

14 Dec 2011, 2:59 PM
#14
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: YouTube in Product Descriptions

Thanks for this Nick

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

14 Jan 2012, 12:41 PM
#15
erwin208 avatar

erwin208

New Zenner

Join Date:
Nov 2005
Posts:
44
Plugin Contributions:
0

Re: YouTube in Product Descriptions

I just get the same results as mentioned by Nick1973

Click on the thumbnail created by zentube and you will see it takes you to the homepage and puts a # in the URL.

You can see at http://www.rainbowtrampolines.nl/shop/test-zen-tube-p-589.html

I didn't read a (clear) solution for this.

14 Jan 2012, 2:21 PM
#16
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: YouTube in Product Descriptions

Well, again, my instructions in there are probably not the best.

You are loading the other scripts before jQuery.

You need to move the jQuery loading line in html_header.php up so that it loads first.

put it here

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>

<?php
/**
 * load all template-specific stylesheets, named like "style*.css", alphabetically
 */

just before the stylesheets and javascript get loaded.

Nick
iszent.com