2

I have done some research on how I can render on a node .tpl page a youtube video, but couldn't find a solution. The module I am using is Video Embed field and Drupal version is Drupal 7.

When doing a print-r content I can see a list of values but I'm unsure on how I can use them to show my video.

Here is the code

 [field_video_url] => Array
                    (
                        [und] => Array
                            (
                                [0] => Array
                                    (
                                        [video_url] => http://www.youtube.com/watch?v=dS4JR0BbKO8
                                        [thumbnail_path] => public://video_embed_field_thumbnails/youtube/dS4JR0BbKO8.jpg
                                        [video_data] => a:21:{s:5:"xmlns";s:27:"http://www.w3.org/2005/Atom";s:11:"xmlns$media";s:29:"http://search.yahoo.com/mrss/";s:8:"xmlns$gd";s:32:
                                        [embed_code] => 
                                        [description] => 
                                    )

                            )

                    )
[#formatter] => video_embed_field
        [0] => Array
            (
                [0] => Array
                    (
                        [#theme] => video_embed_field_embed_code
                        [#url] => http://www.youtube.com/watch?v=dS4JR0BbKO8
                        [#style] => normal
                        [#video_data] => Array
                            (
                                [xmlns] => http://www.w3.org/2005/Atom
                                [xmlns$media] => http://search.yahoo.com/mrss/
                                [xmlns$gd] => http://schemas.google.com/g/2005
                                [xmlns$yt] => http://gdata.youtube.com/schemas/2007
                                [gd$etag] => W/"CUACRn47eCp7I2A9XRZbFU8."
                                [id] => tag:youtube.com,2008:video:dS4JR0BbKO8
                                [published] => 2011-12-12T08:23:43.000Z
                                [updated] => 2014-08-20T08:36:07.000Z
                                [category] => Array
                                    (
                                        [0] => Array
                                            (
                                                [scheme] => http://schemas.google.com/g/2005#kind
                                                [term] => http://gdata.youtube.com/schemas/2007#video
                                            )

                                        [1] => Array
                                            (
                                                [scheme] => http://gdata.youtube.com/schemas/2007/categories.cat
                                                [term] => Tech
                                                [label] => Science & Technology
                                            )

                                    )

                                [title] => Introduction to Theming Basics for Drupal 7
                                [content] => Array
                                    (
                                        [type] => application/x-shockwave-flash
                                        [src] => http://www.youtube.com/v/dS4JR0BbKO8?version=3&f=videos&app=youtube_gdata
                                    )

                                [link] => Array
                                    (
                                        [0] => Array
                                            (
                                                [rel] => alternate
                                                [type] => text/html
                                                [href] => http://www.youtube.com/watch?v=dS4JR0BbKO8&feature=youtube_gdata
                                            )

                                        [1] => Array
                                            (
                                                [rel] => http://gdata.youtube.com/schemas/2007#video.related
                                                [type] => application/atom+xml
                                                [href] => http://gdata.youtube.com/feeds/api/videos/dS4JR0BbKO8/related?v=2
                                            )

                                        [2] => Array
                                            (
                                                [rel] => http://gdata.youtube.com/schemas/2007#mobile
                                                [type] => text/html
                                                [href] => http://m.youtube.com/details?v=dS4JR0BbKO8
                                            )

                                        [3] => Array
                                            (
                                                [rel] => http://gdata.youtube.com/schemas/2007#uploader
                                                [type] => application/atom+xml
                                                [href] => http://gdata.youtube.com/feeds/api/users/yLF5zO6ghZcOXKHRWTipvw?v=2
                                            )

                                        [4] => Array
                                            (
                                                [rel] => self
                                                [type] => application/atom+xml
                                                [href] => http://gdata.youtube.com/feeds/api/videos/dS4JR0BbKO8?v=2
                                            )

                                    )

                                [author] => Array
                                    (
                                        [0] => Array
                                            (
                                                [name] => Drupalize.Me
                                                [uri] => http://gdata.youtube.com/feeds/api/users/Lullabot
                                                [yt$userId] => yLF5zO6ghZcOXKHRWTipvw
                                            )

                                    )

                                [yt$accessControl] => Array
                                    (
                                        [0] => Array
                                            (
                                                [action] => comment
                                                [permission] => allowed
                                            )

                                        [1] => Array
                                            (
                                                [action] => commentVote
                                                [permission] => allowed
                                            )

                                        [2] => Array
                                            (
                                                [action] => videoRespond
                                                [permission] => moderated
                                            )

                                        [3] => Array
                                            (
                                                [action] => rate
                                                [permission] => allowed
                                            )

                                        [4] => Array
                                            (
                                                [action] => embed
                                                [permission] => allowed
                                            )

                                        [5] => Array
                                            (
                                                [action] => list
                                                [permission] => allowed
                                            )

                                        [6] => Array
                                            (
                                                [action] => autoPlay
                                                [permission] => allowed
                                            )

                                        [7] => Array
                                            (
                                                [action] => syndicate
                                                [permission] => allowed
                                            )

                                    )

                                [gd$comments] => Array
                                    (
                                        [gd$feedLink] => Array
                                            (
                                                [rel] => http://gdata.youtube.com/schemas/2007#comments
                                                [href] => http://gdata.youtube.com/feeds/api/videos/dS4JR0BbKO8/comments?v=2
                                                [countHint] => 17
                                            )

                                    )

                                [media$group] => Array
                                    (
                                        [media$category] => Array
                                            (
                                                [0] => Tech
                                            )

                                        [media$content] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [url] => http://www.youtube.com/v/dS4JR0BbKO8?version=3&f=videos&app=youtube_gdata
                                                        [type] => application/x-shockwave-flash
                                                        [medium] => video
                                                        [isDefault] => true
                                                        [expression] => full
                                                        [duration] => 1153
                                                        [yt$format] => 5
                                                    )

                                                [1] => Array
                                                    (
                                                        [url] => rtsp://r3---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQnvKFtARwkudRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
                                                        [type] => video/3gpp
                                                        [medium] => video
                                                        [expression] => full
                                                        [duration] => 1153
                                                        [yt$format] => 1
                                                    )

                                                [2] => Array
                                                    (
                                                        [url] => rtsp://r3---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQnvKFtARwkudRMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
                                                        [type] => video/3gpp
                                                        [medium] => video
                                                        [expression] => full
                                                        [duration] => 1153
                                                        [yt$format] => 6
                                                    )

                                            )

                                        [media$credit] => Array
                                            (
                                                [0] => lullabot
                                            )

                                        [media$description] => Discover hundreds more Drupal tutorial videos at Drupalize.Me/Videos.

I tried the code below but it doesn't work.

    <?php print $content['field_video_url]']['#formatter'][0]['#url'];?>    

I had looked at his link but I'm not really understanding how it is working for him https://stackoverflow.com/questions/21282194/drupal-7-calling-video-embed-field-from-template-file

Many thanks for your help.

0

If you are not trying to do anything fancy, and it is a module-provided video field, Drupal's render function should be enough:

<?php print render($content['field_video_url']);?> 
  • Thank you but unfortunately this doesn't work – amara Aug 24 '14 at 20:15
  • 1
    @amara "doesn't work" is most useless report in IT. It caused syntax error? Runtime error? Watchdog report? Died silently? Does is thow your field if you directly print render($content);? – Mołot Aug 25 '14 at 6:23
  • sorry about the lack of details. It doesn't show anything on the front page when I render ($content['field_video_url']). When I go to the back-end this message error is coming "Notice: Undefined index: field_video_url] in include()" However it does show the video when I do print render($content); – amara Aug 25 '14 at 11:10
  • 1
    Update:I'm not sure how, maybe issue with the cache but after writting print render($content), I then could see the video while writing this code <?php print render($content['field_video_url]']);?>. So it works thank you for your help! – amara Aug 26 '14 at 16:17
  • 1
    @amara cache issues are burden we all need live with :) – Mołot Aug 27 '14 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.