web-dev-qa-db-ja.com

ビデオ埋め込みフィールドを使用してテンプレートページにビデオURLをレンダリングする方法

ノードの.tplページにYouTube動画をレンダリングする方法についていくつか調査しましたが、解決策が見つかりませんでした。私が使用しているモジュールは Video Embed field およびDrupal version is Drupal 7.です。

Print-rコンテンツを実行すると、値のリストを表示できますが、それらを使用して自分のビデオを表示する方法がわかりません。

これがコードです

 [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.

以下のコードを試してみましたが、機能しません。

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

私は彼のリンクを見ましたが、彼にとってどのように機能しているのか本当に理解していません https://stackoverflow.com/questions/21282194/drupal-7-calling-video-embed-field-from-template -ファイル

ご協力いただき誠にありがとうございます。

2
amara

特別なことをしようとせず、それがモジュール提供のビデオフィールドである場合は、Drupalのrender関数で十分です。

<?php print render($content['field_video_url']);?> 
0
Mołot