承接 restruct/silverstripe-oembeddable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

restruct/silverstripe-oembeddable

Composer 安装命令:

composer require restruct/silverstripe-oembeddable

包简介

OEmbed field (extracted from sheadawson/linkable)

关键字:

README 文档

README

This module contains an OEmbeddable DataObject and a OEmbeddableField to easily add oEmbed content to a DataObject or Page. These were extracted, renamed & improved from linkable so they can be used on their own. (We use NamedLinkField module instead of Linkable).

Example usage

Add a $has_one to OEmbeddable and insert OEmbeddableField to manage its contents.

use Restruct\Silverstripe\OEmbedable\OEmbeddable;
use Restruct\Silverstripe\OEmbedable\OEmbeddableField;

class Page extends SiteTree
{
	private static $has_one = [
		'EmbedVideo' => OEmbeddable::class,
	];

	public function getCMSFields()
	{
		$fields = parent::getCMSFields();

		$fields->addFieldToTab(
		    'Root.Main',
		    OEmbeddableField::create(
		        'EmbedVideo',
		        'Video from oEmbed URL',
		        $this->EmbedVideo()
		    )
		);

		return $fields;
	}
}

In your template, you can render the object with the name of the has_one relation

$EmbedVideo

You can also access other metadata on the object via

<h1>$EmbedVideo.Title</h1>
$EmbedVideo.Description
$EmbedVideo.ThumbURL

Switching from Linkable to OEmbeddable

Probably you should be able to use the upgrader tool, the new classnames are included in .upgrade.yml but I haven't tested this.

To upgrade manually, simply remove the Linkable module

Keep Linkable module alongside OEmbeddable

NOTE: in case you're actually using the Linkable fields you may either just stay with that module OR change the $table_name for OEmbeddable (or the EmbeddedObject of Linkable). Then the two should be able to coexist peacefully alongside eachother. (In the SS4 updated version of Linkable we had to correct the value $table_name anyway).

You may correct the value of $db_field after a SS3->4 upgrade via Yaml config:

Sheadawson\Linkable\Models\EmbeddedObject:
  table_name: 'EmbeddedObject'

You may update/change its value (or that of OEmbeddable) to make the two work alongside:

Sheadawson\Linkable\Models\EmbeddedObject:
  table_name: 'LinkableEmbeddedObject' # this way OEmbeddable can use EmbeddedObject as table_name

OR change OEmbeddable to use a different table_name (remember to also correct that of Linkable):

Restruct\Silverstripe\OEmbedable\OEmbeddable:
  table_name: 'OEmbeddable'

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2021-06-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固