Embedding Youtube video

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Locked
SimonF
Forum Members
Forum Members
Posts: 24
Joined: Fri Feb 05, 2016 9:42 pm

Embedding Youtube video

Post by SimonF »

Hello folks,

Have been trying to embed a Youtube video. Whilst copying the Embed URL produced by Youtube works fine, with the iFrame tags, it's not resizeable for a fluid site.

I've been trying to read up on how to do it & have tried this from the CMS Documentation using the Embed tag.

http://docs.cmsmadesimple.org/tags/cmsms-tags/embed

This is the error I now get:

Code: Select all

Syntax error in template "content:content_en"  on line 14 "
{embed url="https://www.youtube.com/watch?v=3qOOocqfkZs"}

" unknown tag "embed"
The embed code from Youtube is this:

Code: Select all

<__iframe width="854" height="480" src="https://www.youtube.com/embed/3qOOocqfkZs" frameborder="0" allowfullscreen></__iframe>
This is the tag I now have in my Content page:

Code: Select all

{embed url="https://www.youtube.com/watch?v=3qOOocqfkZs"}
I've added {embed header=true} to the Simplex Template and the

Code: Select all

#myframe {
height: 600px;
}
to both the Simplex Core and Layout stylesheets.

Can anyone please tell me what I'm doing wrong?

Regards,

Simon
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Embedding Youtube video

Post by Rolf »

Create a UDT named "youtube" with the content:

Code: Select all

$id = isset($params['id']) ? $params['id'] : '';

if ( $id != '' )
{
  echo '<div class="video">';
  echo '<__iframe width="560" height="315" src="//www.youtube.com/embed/' . $id . '?rel=0&showinfo=0" frameborder="0" allowfullscreen></__iframe>';
  echo '</div>';
}
NOTE: remove the __ in the iframe tags in the code --^

In your page or article:

Code: Select all

{youtube id='3qOOocqfkZs'}
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm
Location: Marlow, UK

Re: Embedding Youtube video

Post by scooper »

Looks like the old embed tag isn't in the new 2.0 version of CMSMS which is why you're getting the error.

I use a very similar User Defined Tag to the one Rolf suggested. It's something I often use so I keep it handy as a gist:

https://gist.github.com/millipedia/10017099

That also includes some CSS classes that you can use to allow it to be resized and keep the aspect ratio when you embed it in a responsive site.

s.
User avatar
master3395
Forum Members
Forum Members
Posts: 94
Joined: Mon Mar 30, 2015 7:13 am
Location: Norway

Re: Embedding Youtube video

Post by master3395 »

2.0 has the new content embedding included.
SimonF
Forum Members
Forum Members
Posts: 24
Joined: Fri Feb 05, 2016 9:42 pm

Re: Embedding Youtube video

Post by SimonF »

So how's it done then, master3395?

The method in the 2.0 Documentation is as I listed above & doesn't work.

Thanks to Scooper & Rolf I have it working after a fashion. The vids still don't shrink below a certain resolution, meaning mobile phone users get left-right scrolling, though I fear this is a Youtube limitation.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: Embedding Youtube video

Post by Jeff »

I don't use a plugin, I simply copy the code from youtube and paste it in my template.

To get a responsive video you need to setup CSS properly. I did it a while back a quick search on google gave me https://css-tricks.com/NetMag/FluidWidt ... hVideo.php I don't know if this is the one I used or not.
SimonF
Forum Members
Forum Members
Posts: 24
Joined: Fri Feb 05, 2016 9:42 pm

Re: Embedding Youtube video

Post by SimonF »

Have the last 2 posters actually read my original post???
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: Embedding Youtube video

Post by Jeff »

Yes, I did and I address both points in my reply.
Locked

Return to “The Lounge”