定制 drnixx/yii2-schema-org 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drnixx/yii2-schema-org

Composer 安装命令:

composer require drnixx/yii2-schema-org

包简介

Schema.org yii2 representation and helpers for json-ld generation in Yii framework

README 文档

README

Schema.org yii2 representation and helpers for json-ld generation

Resources

Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require --prefer-dist drnixx/yii2-schema-org

or add

"drnixx/yii2-schema-org": "*"

to the require section of your composer.json

Usage

Setup Module

Configure the module named schema in the modules section of your Yii configuration file. Do this for console and for web application configuration file.

'modules' => [
	'schema' => [
		'class' => 'drnixx\schemaorg\Module',
		//'source' => 'http://schema.org/docs/full.html',
		//'autoCreate' => false,
		//'autoRender' => false
	]
]

Also add the module schema to the bootstrap section of your configuration files:

'bootstrap' => ['log', 'schema']

Configuration

source

The source parameter defines the root url of schema.org property documentation. It is used to automatically create the models in console application.

autoCreate

Automatically create breadcrumbs json+ld data.

autoRender

Automatically render json+ld data at the end of body section.

If you don't use this parameter, be sure to call JsonLDHelper::render() in your layout file. Example:

<?php
/* @var $this \yii\web\View */
/* @var $content string */
use app\widgets\Alert;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use drnixx\schemaorg\helpers\JsonLDHelper;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php JsonLDHelper::render(); ?>
    <?php $this->head() ?>
</head>

Model generation

$ php yii schema/schema-org

Example Usage

To e.g. add a person to json+ld, you can do the following:

use drnixx\schemaorg\models\Person;
use drnixx\schemaorg\helpers\JsonLDHelper;

$child = new Person();
$child->name = 'George W. Bush';
$child->disambiguatingDescription = '43rd President of the United States';
$person = new Person();
$person->name = 'George Bush';
$person->disambiguatingDescription = '41st President of the United States';
$person->children = [$child];

JsonLDHelper::add($person);

License

yii2-schema-org is released under MIT license. See bundled LICENSE for details.

统计信息

  • 总下载量: 168
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固