heimrichhannot / contao-youtube-bundle
此包已废弃,不再维护。作者建议使用 https://github.com/heimrichhannot/contao-video-bundle 包。
支持响应式的 YouTube 内容元素,预览图片,播放按钮等。
3.10.3
2024-02-12 12:24 UTC
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.9
- heimrichhannot-contao-components/alertifyjs: 1.11.2
- heimrichhannot/contao-encore-contracts: ^1.0
- heimrichhannot/contao-request-bundle: ^1.2
- heimrichhannot/contao-utils-bundle: ^2.60
- symfony/service-contracts: ^1.0 || ^2.0 || ^3.0
- twig/twig: ^1.44.6 || ^2.14 || ^3.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- contao/test-case: ^1.1
- friendsofphp/php-cs-fixer: ^2.2
- php-coveralls/php-coveralls: ^2.0
- php-http/guzzle6-adapter: ^1.1
- php-http/message-factory: ^1.0.2
- phpunit/phpunit: >=6.0 <6.5
- symfony/phpunit-bridge: ^3.2
Suggests
- heimrichhannot/contao-encore-bundle: Manage dependencies with Symfony Webpack Encore.
- dev-master
- v3.x-dev
- 3.10.3
- 3.10.2
- 3.10.1
- 3.10.0
- 3.9.12
- 3.9.11
- 3.9.10
- 3.9.9
- 3.9.8
- 3.9.7
- 3.9.6
- 3.9.5
- 3.9.4
- 3.9.3
- 3.9.2
- 3.9.1
- 3.9.0
- 3.8.0
- 3.7.10
- 3.7.9
- 3.7.8
- 3.7.7
- 3.7.6
- 3.7.5
- 3.7.4
- 3.7.3
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.1
- 3.6.0
- 3.5.2
- 3.5.1
- 3.5.0
- 3.4.1
- 3.4.0
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.1
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.1
- 3.0.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- dev-feauture/encore_contracts
This package is auto-updated.
Last update: 2024-02-12 12:25:04 UTC
README
YouTube-Bundle 已不再积极维护,因为我们开发了后续的包: 视频包。
YouTube 包旨在提供具有预览图片和更好的隐私控制的响应式 YouTube 视频。它支持内容元素和新闻条目。
需要有效的 YouTube 数据 API 密钥 以支持自动预览图片(在 Contao 系统设置或根页面上输入)。
如果您从 heimrichhannot/contao-youtube 升级,请参阅 升级通知。
特性
- 响应式 YouTube 视频
- YouTube 视频的预览图片
- 如果没有提供自定义图片,预览图片将从 YouTube 加载并保存到 'files/media/youtube/'
- 为 List- 和 Readerbundle 提供 ConfigElements。
- Encore Bundle 支持
- 隐私模式
- 在隐私模式下,视频将在用户在接受模态提示中的隐私建议后显示
- 用户可以通过复选框将其选择标记为永久(状态将保存在cookie中)
技术说明
添加到列表和阅读器条目模板
对于与 List- 和 Readerbundle 一起使用,您首先需要在 List- 和/或 Reader 配置中添加配置元素。
之后,您可以将 YouTube 添加到模板中。配置元素添加了一个格式化的值 youtubeVideos
,其中包含由配置元素添加的每个 YouTube 字段的数组。
$templateData = [ // ... 'youtubeVideos' => [ 'youtubeField' => [ // The selected youtube field name from config element 'video' => '' // Generated default template, 'data' => [] // Video data for custom templates ] ] ]
示例自定义模板
{% if raw.addYouTube == "1" and youtubeVideos.youtube|default%} {% include '@VendorMyBundle/youtube/youtube_video_custom.html.twig' with youtubeVideos.youtube.data %} {% endif %}
新闻模板
可以轻松地将 YouTube 视频添加到新闻模板中。只需添加以下代码(例如:news_full.html5)
<?php if($this->youtube && $this->youtube->video): ?>
<?= $this->youtube->video; ?>
<?php endif; ?>
YouTube 的预览图片
要使用 YouTube 的预览图片,您必须生成一个 API 密钥 (https://developers.google.com/youtube/v3/getting-started) 并将其放置在 Contao 设置中。
命令
迁移命令
Usage:
huh:youtube:migration [options]
Options:
--dry-run Performs a run without writing to database.
--migration=MIGRATION Do migration directly without interrupt. Options: module, database, both, none
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The Environment name. [default: "prod"]
--no-debug Switches off debug mode.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
This command provide migration scripts to migrate from heimrichhannot/contao-youtube to heimrichhannot/contao-youtube-bundle.
Available migrations:
'module' updates default template names and field values
'database' updates database fields that can't be updated by the contao install tool.
'both' will run 'module' and 'database' migrations.
开发者
事件
事件 | 事件ID |
---|---|
与AlertifyJs的'显示'事件交互的事件 | huh.youtube.event.alertify.onshow |
与AlertifyJs的'聚焦'事件交互的事件 | huh.youtube.event.alertify.onfocus |
从heimrichhannot/contao-youtube的升级通知
- 使用
huh:youtube:migration
命令迁移根页面和relatedYoutubeNews数据库字段中的默认模板设置 - 在tl_settings或tl_page中声明一个YouTube-API密钥(否则预览图片下载将无法工作)
- 隐私对话框或模态视频的模态窗口需要额外的CSS,该CSS由包本身不提供。标记符合Bootstrap模态窗口CSS,因此建议使用该框架的CSS。
- 如果您使用的是自定义的YouTube
.html5
模板,需要将它们迁移到.html.twig
模板,如需帮助,请检查默认模板