• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Embed YouTube videos with valid XHTML
PostPosted: Thu Feb 28, 2008 12:22 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Jan 25, 2007 2:54 pm
Posts: 124
Location: España / Hispanujo / Spain
The default HTML provided by YouTube is not valid XHTML. I wrote a very simple tag to embed YouTube videos with valid XHTML (I googled this site, and it seems there was nothing about this yet).

I put it in the wiki: Embed YouTube videos with valid XHTML.

_________________
Marcos Cruz


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Sat Sep 27, 2008 10:08 pm 
Offline
New Member

Joined: Sat Sep 27, 2008 9:58 pm
Posts: 4
This is fantastic.  I wonder--is it possible to alter the User Defined Tag to allow YouTube videos to play in full size mode?  This requires adding parameters along the lines of in a couple of places in the code.  I'm not expert enough to change it, although I managed to use your 'youtube_video' tag for my site.

Thanks so much,
JEP


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Tue Sep 30, 2008 10:12 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Jan 25, 2007 2:54 pm
Posts: 124
Location: España / Hispanujo / Spain
JEPad wrote:
is it possible to alter the User Defined Tag to allow YouTube videos to play in full size mode?  This requires adding parameters along the lines of in a couple of places in the code.


Thanks for the suggestion. I've found the YouTube Embedded Player Parameters, but I'm not pretty sure how to use them with the valid XHTML version. Maybe this way:

Code:
/*
Embed a YouTube video with valid XHTML
Parameter: url
Reference: http://www.bernzilla.com/item.php?id=681
*/
echo '<object class="youtube" type="application/x-shockwave-flash" width="425" height="350"';
echo ' data="'.$params['url'].'">';
echo '<param name="movie" value="'.$params['url'].'" />';
echo '<param name="allowFullScreen" value="true" />';
echo '</object>';


I cannot test it right now. May you try it?

_________________
Marcos Cruz


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Tue Sep 30, 2008 12:23 pm 
Offline
New Member

Joined: Sat Sep 27, 2008 9:58 pm
Posts: 4
It works!  Thanks!


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Wed Oct 01, 2008 10:36 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Jan 25, 2007 2:54 pm
Posts: 124
Location: España / Hispanujo / Spain
JEPad wrote:
It works!  Thanks!


Glad to know. I updated the wiki with a note about additional video parameters and a link to this thread. It can be useful for others.

_________________
Marcos Cruz


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Fri Oct 10, 2008 4:55 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Sat Sep 27, 2008 8:00 am
Posts: 21
Location: Israel
Hi alinome.net...
Your code inspired me to write this one...
Code:
function smarty_cms_function_youtube($params, &$smarty)
{
   global $gCms;
   if(isset($params['id']))
   {
      $id = $params['id'];
   }
   elseif(isset($params['url']))
   {
      list(,$url) = explode('?',$params[url],2);
      parse_str($url,$to);
      $id = $to[v];
   }
   if(isset($id)) {
      $var = <<<EOF
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/$id"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/$id" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355">
</embed>
</object>
EOF;
   }
   else $var = "error calling {youtube} function";
return $var;
}

I hope you'll like it.... enjoy


Last edited by confiq on Fri Oct 10, 2008 5:29 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Mon Oct 13, 2008 12:44 pm 
Offline
New Member

Joined: Thu Oct 09, 2008 9:43 am
Posts: 7
config
But your code seems NOT to be a valid xhtml. Is it valid xhtml?
Thanks.


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Mon Oct 13, 2008 3:20 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Sat Sep 27, 2008 8:00 am
Posts: 21
Location: Israel
i didn't check but it's copy paste from your code...
I didn't change HTML a bit...


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Thu Sep 10, 2009 6:54 pm 
Offline
Beta Tester
Beta Tester
User avatar

Joined: Tue Nov 21, 2006 5:05 pm
Posts: 249
Location: Nashville, USA
This was very helpful to create a tag for an editor to use in Articles and Pages, etc.  But, it would not play in IE7/8. So, although this is not completely valid b/c it uses IE conditional comments, this modification will play in IE browsers.

Code:
/*
Embed a YouTube video with valid XHTML
Parameter: url
Reference: http://www.bernzilla.com/item.php?id=681
Cross Browser Compatible Version - Tested in IE7, 8, Firefox 3+, Safari 4
*/
echo '<![if !IE]><object class="youtube" type="application/x-shockwave-flash" width="445" height="364" data="'.$params['url'].'"><![endif]>';
echo '<!--[if IE]><object class="youtube" width="445" height="364" data="'.$params['url'].'"><![endif]-->';
echo '<param name="movie" value="'.$params['url'].'" />';
echo '<param name="wmode" value="transparent" />';
echo '<param name="allowFullScreen" value="true" />';
echo '<param name="allowscriptaccess" value="always" />';
echo '<!--[if IE]>
      <embed src="'.$params['url'].'" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" width="445" height="364"></embed>
      <![endif]-->';
echo '</object>';

_________________
--
LinkedIn.com
--
Internal Page 301 Redirect
--
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo


Last edited by mww on Thu Sep 10, 2009 6:57 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Tue Oct 27, 2009 4:07 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Jul 24, 2008 7:27 pm
Posts: 82
Location: Florida, USA
Thanks for the UDT. It worked great! I used the code submitted by mww and added 'height' and 'width' parameters since I was embedding videos with different aspect ratios. It will default to 425x355 if nothing is entered though. I also put the browser detection in php.

Code:
/*
Embed a YouTube video with valid XHTML
Parameter: url, width, height
Cross Browser Compatible Version - Tested in IE7, 8, Firefox 3+, Safari 4
*/
if (isset($params['width'])) { $width = $params['width']; } else { $width == 425; }
if (isset($params['height'])) { $height = $params['height']; } else { $height == 355; }
$browser = get_browser();
if($browser->browser == 'IE') {
   echo '<object class="youtube" width="'.$width.'" height="'.$height.'" data="'.$params['url'].'">\n';
   echo '<embed src="'.$params['url'].'" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" width="'.$width.'" height="'.$height.'"></embed>';
} else {
   echo '<object class="youtube" type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'" data="'.$params['url'].'">';
}
echo '<param name="movie" value="'.$params['url'].'" />';
echo '<param name="wmode" value="transparent" />';
echo '<param name="allowFullScreen" value="true" />';
echo '<param name="allowscriptaccess" value="always" />';
echo '</object>';


Last edited by bryan on Tue Oct 27, 2009 7:22 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Mon Nov 09, 2009 2:56 pm 
Offline
Forum Members
Forum Members

Joined: Wed Oct 15, 2008 11:03 am
Posts: 21
bryan wrote:
Thanks for the UDT. It worked great! I used the code submitted by mww and added 'height' and 'width' parameters since I was embedding videos with different aspect ratios. It will default to 425x355 if nothing is entered though. I also put the browser detection in php.

Code:
/*
Embed a YouTube video with valid XHTML
Parameter: url, width, height
Cross Browser Compatible Version - Tested in IE7, 8, Firefox 3+, Safari 4
*/
if (isset($params['width'])) { $width = $params['width']; } else { $width == 425; }
if (isset($params['height'])) { $height = $params['height']; } else { $height == 355; }
$browser = get_browser();
if($browser->browser == 'IE') {
   echo '<object class="youtube" width="'.$width.'" height="'.$height.'" data="'.$params['url'].'">\n';
   echo '<embed src="'.$params['url'].'" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" width="'.$width.'" height="'.$height.'"></embed>';
} else {
   echo '<object class="youtube" type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'" data="'.$params['url'].'">';
}
echo '<param name="movie" value="'.$params['url'].'" />';
echo '<param name="wmode" value="transparent" />';
echo '<param name="allowFullScreen" value="true" />';
echo '<param name="allowscriptaccess" value="always" />';
echo '</object>';



I tried your code, because I liked the control over size, but there is an error-code above the embedded youtube object:

Warning: get_browser() [function.get-browser]: browscap ini directive not set in [link to root of the cmsms mle installation]/lib/content.functions.php(771) : eval()'d code on line 8

I'm using CMSMS 1.6.6 mle , PHP 5.2.10

Somebody any pointers? I'm not that skilled in PHP.


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Tue Nov 10, 2009 10:07 pm 
Offline
Forum Members
Forum Members

Joined: Tue Nov 10, 2009 10:04 pm
Posts: 68
Can anyone tell me how to add this youtube tag to the CMS?
Do i need to make an PHP file? or do i need to donwload one?

Hope someone can help this newbie.


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Wed Nov 11, 2009 1:33 am 
Offline
New Member

Joined: Tue Oct 21, 2008 6:09 am
Posts: 2
voorhammr wrote:
Can anyone tell me how to add this youtube tag to the CMS?
Do i need to make an PHP file? or do i need to donwload one?

Hope someone can help this newbie.



Just create a user defined tag (Extensions -> User Defined Tag).

Click on Add User Defined Tag

Enter the tag name and paste the code in to the Code box.

That's it.


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Mon Nov 16, 2009 2:50 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Fri Nov 30, 2007 9:15 am
Posts: 329
Hi all,

For embedding youtube video's with full screen button and not displaying related video's afterwards, create a user-defined tag with the following code:

echo '';
echo '';
echo '';
echo 'echo 'allowfullscreen="true" width="425" height="344">';
echo '
';

Greetings,
Manuel

_________________
Do you like your open source cms? Buy from the CMSMS partners || Donate
(or at least share some knowledge :D >> See some of my stuff )


Top
 Profile  
 
 Post subject: Re: Embed YouTube videos with valid XHTML
PostPosted: Wed Nov 18, 2009 4:47 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Jul 24, 2008 7:27 pm
Posts: 82
Location: Florida, USA
ElBombo wrote:
I tried your code, because I liked the control over size, but there is an error-code above the embedded youtube object:

Warning: get_browser() [function.get-browser]: browscap ini directive not set in [link to root of the cmsms mle installation]/lib/content.functions.php(771) : eval()'d code on line 8

I'm using CMSMS 1.6.6 mle , PHP 5.2.10

Somebody any pointers? I'm not that skilled in PHP.


After doing some research it seems that there are some compatability issues between browscap.ini and the later versions of PHP. My server is running php 5.1.6 and I don't seem to have any trouble calling to get_browser(). You can use JQuery.browser to create a conditional statement instead of PHP:
http://docs.jquery.com/Utilities/jQuery.browser


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
A2 Hosting