dmstr/yii2-social-media-widgets

Yii2 Social Media Widgets

Installs: 4 530

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 9

Forks: 1

Open Issues: 0

Type:yii2-extension

0.0.3 2020-12-08 13:14 UTC

This package is auto-updated.

Last update: 2024-10-08 21:40:48 UTC


README

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist dmstr/yii2-social-media-widgets

or add

"dmstr/yii2-social-media-widgets": "*"

to the require section of your composer.json file.

Usage

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
}) }}

In combination with the dmstr yii2 widgets2 module you are may be interested in a json editor schema:

{
    "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"
        }
    }
}