gorriecoe / silverstripe-action
添加基本的行动号召数据对象。
dev-master
2018-07-15 22:25 UTC
Requires
- gorriecoe/silverstripe-link: ^1.0
- gorriecoe/silverstripe-preview: dev-master
- silverstripe/framework: ^4.0
This package is auto-updated.
Last update: 2024-08-29 04:25:46 UTC
README
添加基本的行动号召数据对象。
安装
Composer 是安装 SilverStripe 模块的推荐方式。
composer require gorriecoe/silverstripe-action
要求
- silverstripe/cms ^4.0
- gorriecoe/silverstripe-link ^1.0
- gorriecoe/silverstripe-preview ^1.0
维护者
用法
use gorriecoe\Action\Models\Action; ... class Page extends SiteTree { private static $many_many = [ 'Actions' => Action::class ]; private static $many_many_extraFields = [ 'Actions' => [ 'Sort' => 'Int' ] ]; public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab( 'Root.Main', [ GridField::create( 'Actions', 'Actions', $this->Actions(), GridFieldConfig_RecordEditor::create() ->addComponent(new GridFieldOrderableRows('Sort')) ) ] ); } }
<% loop Actions.sort('Sort ASC') %>
<% with Preview %>
<div class="call-to-action">
{$Image.Fill(300,200)}
<h2>
{$Title}
</h2>
<p>
{$Summary.Summary}
</p>
<a href="{$LinkURL}">
{$Label}
</a>
</div>
<% end_with %>
<% end_loop %>