stnvh/silverstripe-taggedfield
Composer 安装命令:
composer require stnvh/silverstripe-taggedfield
包简介
Creates a tag field, similar to how a ListBoxField looks.
README 文档
README
Creates a tag field, similar to how a ListBoxField looks.
By Stan Hutcheon - Bigfork Ltd
Installation:
Composer:
composer require "stnvh/silverstripe-taggedfield" "~1"
Download:
Clone this repo into a folder called taggedfield in your silverstripe installation folder.
Usage:
Initialize it like any other field. Make sure you have a 'Text' entry in the database to store the values:
<?php class MyObject extends DataObject { private static $db = array( 'Tags' => 'Text' ); public function getCMSFields() { $fields = parent::getCMSFields(); $taggedField = TaggedField::create('Tags'); $fields->addFieldToTab('Root.Main', $taggedField); return $fields; } // To use the tags in the template correctly public function Tags() { $tags = explode(',', $this->Tags); foreach($tags as $i => $tag) { $tags[$i] = array('Tag' => $tag); } return ArrayList::create($tags); } }
In the template:
<% loop Tags %> <span class="tag">{$Tag}</span> <% end_loop %>
After installing via composer, you must /dev/build
统计信息
- 总下载量: 918
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-10-20