dmstr / yii2-social-media-widgets
Yii2 社交媒体小部件
0.0.3
2020-12-08 13:14 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-08 21:28:19 UTC
README
安装
安装此扩展的首选方式是通过 Composer。
运行以下命令之一:
composer require --prefer-dist dmstr/yii2-social-media-widgets
或将以下内容添加到您的 composer.json
文件的 require 部分:
"dmstr/yii2-social-media-widgets": "*"
使用方法
PHP
use dmstr\socialmediawidgets\widgets\SocialMediaMeta; SocialMediaMeta::widget([ 'title' => 'Title', 'description' => 'Lorem ipsum dolor sit amet', 'image' => 'https://example.com/example.png', 'url' => 'https://example.com/mypage', 'siteName' => 'Site Name', 'twitterImageAlt' => 'Alt Text' ]);
TWIG
{{ use ('dmstr/socialmediawidgets/widgets/SocialMediaMeta') }} {{ SocialMediaMeta_widget({ title: title, description: description, image: image(image), url: url, siteName: siteName, twitterImageAlt: twitterImageAlt }) }}
结合 dmstr yii2 widgets2 模块,您可能还对 json 编辑器模式感兴趣
{ "title": "SEO Social Media", "type": "object", "properties": { "title": { "title": "Title", "type": "string", "minLength": 1 }, "description": { "title": "Description", "type": "string", "minLength": 1 }, "image": { "title": "Image", "type": "string", "format": "filefly", "minLength": 1 }, "url": { "title": "URL", "type": "string" }, "siteName": { "title": "Site Name", "type": "string" }, "twitterImageAlt": { "title": "Twitter Image Alt", "type": "string" } } }