Jump to content

Youtube Template Tag


sobrenome

Recommended Posts

I am creating a custom database which one of the fields will be to record the related youtube url for the content.

So I have to make a custom record display template to show the youtube video embended. I dont want to use the ckeditor for that. 

Link to comment
Share on other sites

I am creating a custom database which one of the fields will be to record the related youtube url for the content.

So I have to make a custom record display template to show the youtube video embended. I dont want to use the ckeditor for that. 

​.

You will need the "template key" or also named "field key" to be set and then you can use that kind of tag in your "listing" or "display" template ..

use it this way ..

{$record->customFieldDisplayByKey('YouTube', 'display')|raw}

 

 

2015-05-19_8-02-33.thumb.png.525b2847ac6

 

 

.

 

Link to comment
Share on other sites

Yes, that's right.

But what I want is a template tag to parse the youtube url to generate the responsive html output for youtube video.

​.

I think what you want just happens automatically if you fit all the pieces together ..

You make a YouTube field > you add a record > fill in the YouTube URL > save .. display the record > YouTube is responsive on its own, it will show the video embedded ..

You creating a custom template > use the field key .. test your template .. Your YouTube should be responsive ..

..

 

.

Link to comment
Share on other sites

Yes, that's right.

But what I want is a template tag to parse the youtube url to generate the responsive html output for youtube video.

​Just add the 100% width as option to the YouTube field and make sure you output the field on its own line so it doesn’t share the space with other elements on that line. 

Link to comment
Share on other sites

I just tried it. Added a YouTube field, added the 100% width parameter in the field options. 

Screen_Shot_2015-05-20_at_07.53.02.thumb

Made sure the field is set to show the player:

Screen_Shot_2015-05-20_at_07.49.35.thumb

And I instantly get the responsive videos in the record view. 
If you change that last option to Plain URL you can of course put your embed code directly in the template. But I don’t think you have to. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...