定制 creativecodelabs/silverstripe-social-meta-tags 二次开发

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

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

creativecodelabs/silverstripe-social-meta-tags

Composer 安装命令:

composer require creativecodelabs/silverstripe-social-meta-tags

包简介

Adds social media meta tags to Silverstripe sites.

README 文档

README

Adds social media meta tags to Silverstripe sites.

Description

silverstripe-social-meta-tags adds social media meta tags for OpenGraph (Facebook) and Twitter to SiteTree and child page types.

Supported social media meta tags include:

  • OpenGraph (Facebook)
    • og:site_name
    • og:title
    • og:image
    • og:description
    • og:url
  • Twitter
    • twitter:site
    • twitter:title
    • twitter:image
    • twitter:description
    • twitter:card

Requirements

SilverStripe 3.5+

Installation

  1. composer require creativecodelabs/silverstripe-social-meta-tags
  2. run a /dev/build?flush=all
  3. Without any configuration, the module will begin rendering social media meta tags for all page types.

Defaults

By default, the module will use the following fields to populate the meta tags:

  • og:type --> "website"
  • og:site_name --> SiteConfig.Title
  • og:title --> Title
  • og:description --> MetaDescription
  • og:url --> AbsoluteLink()
  • twitter:title --> Title
  • twitter:description --> MetaDescription
  • twitter:card --> "summary"

NOTE: twitter:card will be set to "summary" by default, unless an image field is used. If an image field is used, the content will be set to "summary_large_image".

Configuration

Configure the module by editing mysite/_config/config.yml and set the following options:

SocialMetaTags:
  default_title: 'PageTitle' 
  default_description: 'MetaDescription' 
  meta_description_default: true 
  twitter_site: '' 
  titles:	
    ClassName: 'FieldName'
    ClassName1: 'FieldName1'
  descriptions:
    ClassName: 'FieldName'
    ClassName1: 'FieldName1'
  images:	
    ClassName: 'FieldName'
    ClassName1: 'FieldName1'
  types:
    ClassName: 'website'
    ClassName1: 'article'
  • default_title - override the default title field to use; PageTitle is used by default.
  • default_description - override the default description field to use; MetaDescription is used by default.
  • meta_description_default - flag that indicates whether to fall back to MetaDescription if the chosen description field is empty.
  • twitter_site - the content to be used for thw twitter:site meta tag.
  • titles - an array of class names, with the value being the name of the Text field to use for title meta tags. Useful for adding social media meta tag output to DataObjects.
  • descriptions - an array of class names, with the value being the name of the Text field to use for description meta tags. Useful for adding social media meta tag output to DataObjects.
  • images - an array of class names, with the value being the name of the Image field to use for image meta tags. Useful for adding social media meta tag output to DataObjects.
  • types - an array of class names, with the value being the content to use for og:type met tag.

Example config.yml

SocialMetaTags:
  default_title: 'PageTitle'
  default_description: ''
  meta_description_default: true
  titles:
    Category: 'Name'
    Product: 'Name'
    Recipe: 'Name'
  descriptions:
    Category: 'ShortDescr'
    Product: 'Summary'
    Recipe: 'MetaDescription'
  images:
    AboutUsPage: 'LogoImage'
    Category: 'BeautyShot'
    Product: 'BeautyShot'
    Recipe: 'Image'
  types:
    Recipe: 'article'
  twitter_site: ''

Adding social media meta tags to DataObjects

By default, this module will only add social media meta tags to SiteTree objects.

To add social media meta tags to DataObjects:

  • in /mysite/_config.php, add the extension to each DataObject class you wish.
    • e.g. Recipe::add_extension('SocialMetaTagsExtension');
  • in /mysite/_config/config.yml, set options for titles, descriptions, and images (if desired) for your class.
    • for an example, see the above example config.yml.
  • in your DataObject's class, add new fields in getCMSFields():
  public function getCMSFields() {
      $fields = parent::getCMSFields();
      
      ...
      
      $fields->addFieldToTab('Root.Main', new TextareaField("SocialMetaDescription"));
      $fields->addFieldToTab('Root.Main', new UploadField("SocialMetaImage"));
      
      return $fields;
  }
  • run a /dev/build?flush=all

License

This project is licensed under GPL v3

creativecodelabs/silverstripe-social-meta-tags 适用场景与选型建议

creativecodelabs/silverstripe-social-meta-tags 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 creativecodelabs/silverstripe-social-meta-tags 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 creativecodelabs/silverstripe-social-meta-tags 我们能提供哪些服务?
定制开发 / 二次开发

基于 creativecodelabs/silverstripe-social-meta-tags 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2018-04-11