plozmun/sulu-schema-org-bundle
Composer 安装命令:
composer require plozmun/sulu-schema-org-bundle
包简介
Sulu Bundle for structured data creation
README 文档
README
This bundle integrates Structured Data from Schema.org to your project.
Instalation
composer requiere plozmun/sulu-schema-org-bundle
Insert this code into your "base.html.twig" so that the entire generated schema is automatically inserted into the response.
{{ constant('Plozmun\\Bundle\\SuluSchemaOrgBundle\\Factory\\SchemaOrgFactory::TWIG_KEY')|raw }}
Now you can define Schema types for each template adding a 'sulu.schema_org' tag for each template and elements.
Basic example in homepage.xml
<key>homepage</key> <tag name="sulu.schema_org" itemtype="WebSite"/> <view>pages/homepage</view> <controller>Sulu\Bundle\WebsiteBundle\Controller\DefaultController::indexAction</controller> <cacheLifetime>86400</cacheLifetime> <meta> <title lang="en">Homepage</title> <title lang="es">Homepage</title> </meta> <properties> <property name="title" type="text_line" mandatory="true"> <meta> <title lang="en">Title</title> <title lang="es">Título</title> </meta> <params> <param name="headline" value="true"/> </params> <tag name="sulu.schema_org" itemtype="WebSite" itemprop="name"/> <tag name="sulu.rlp.part"/> </property> <property name="url" type="resource_locator" mandatory="true"> <meta> <title lang="es">Slug</title> <title lang="en">Slug</title> </meta> <tag name="sulu.schema_org" itemtype="WebSite" itemprop="url"/> <tag name="sulu.rlp"/> </property> </properties> </template>
Generated code:
<script type="application/ld+json"> { "@context":"https:\/\/schema.org", "@type":"WebSite", "name":"Homepage", "url":"\/", "description":"Metadescription", "datePublished":"2020-05-20T12:33:59+02:00" } </script>
There are some useful options for self-assigning Seo and Extracts properties
sulu_schema_org: # image format generated for all image types image_format: "sulu-240x" organization: enabled: true schema: EducationalOrganization uid: main extensions: seo: default: title: property: name type: text_line description: property: description type: text_line Article: description: property: headline type: text_line excerpt: default: icon: property: image type: media_selection
Tags in blocks
You can define properties in all blocks of the project by assigning the fields according to the scope.
<type name="hero"> <meta> <title lang="es">01M - Hero</title> <title lang="en">01M - Hero</title> </meta> <properties> <property name="title" type="text_line" mandatory="true"> <meta> <title lang="es">Título</title> <title lang="en">Title</title> </meta> </property> <property name="images" type="media_selection" mandatory="true" maxOccurs="1"> <meta> <title lang="es">Imágenes</title> <title lang="en">Images</title> </meta> <tag name="sulu.schema_org" itemtype="WebSite" itemprop="image"/> </property> </properties> </type>
Sometimes the field is used in multiple scopes, then you can change 'itemtype' property by "*"
<tag name="sulu.schema_org" itemtype="*" itemprop="image"/>
Complex structures
Many schemas define child objects, like Addrees in a Event, so you must register all in template with its scope. The property itemscope defines the parent so you must specify
<tag name="sulu.schema_org" itemtype="Event"/>
<tag name="sulu.schema_org" itemtype="Place" itemscope="Event" itemprop="location" />
<tag name="sulu.schema_org" itemtype="PostalAddress" itemscope="Place" itemprop="address" />
Now if a property with itemtype="PostalAddress exists in your code it will be assigned to its schema:
<property name="city" type="text_line" mandatory="true"> <meta> <title lang="en">City</title> </meta> <tag name="sulu.schema_org" itemtype="PostalAddress" itemscope="Place" itemprop="addressLocality" /> </property> <property name="zip" type="text_line" mandatory="true"> <meta> <title lang="en">Zip</title> </meta> <tag name="sulu.schema_org" itemtype="PostalAddress" itemscope="Place" itemprop="postalCode" /> </property> ...
Breadcrumb
There is a Twig Function to generate Breadcrumb schema. Put in any place of your twig templates:
{{ sulu_schema_org('breadcrumb', breadcrumb) }}
Organizations
If organitation option is enabled in configuration. An Organization Schema with uid defined will be inyected in schema list. You must specify the type of your organization. See some types here
plozmun/sulu-schema-org-bundle 适用场景与选型建议
plozmun/sulu-schema-org-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 174 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 plozmun/sulu-schema-org-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 plozmun/sulu-schema-org-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 174
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-07