danrye / silverstripe-tagfield

SilverStripe module for editing tags (both in the CMS and other forms)

Home Page:http://silverstripe.org/tag-field-module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TagField Module

Build Status Code Quality

Requirements

  • SilverStripe 3.1 or newer
  • Database: MySQL 5+, SQLite3, Postgres 8.3, SQL Server 2008

Download/Information

Usage

Relational Tags w/ Extension

class Tag extends DataObject {
    static $db = array(
        'Title' => 'Varchar(200)',
    );

    static $belongs_many_many = array(
    	'BlogPosts' => 'BlogPost'
    );
}
BlogPost:
  extensions:
    - TaggableExtension

Relational Tags

class BlogPost extends DataObject {
	static $many_many = array(
		'BlogTags' => 'BlogTag'
	);
}
class BlogTag extends DataObject {
	static $db = array(
		'Title' => 'Varchar(200)',
	);

	static $belongs_many_many = array(
		'BlogPosts' => 'BlogPost'
	);
}
$field = new TagField(
	'BlogTags', 'Blog Tags', BlogTags::get(), $post->BlogTags()
);

$field->setShouldLazyLoad(true); // tags should be lazy loaded
$field->setCanCreate(true);      // new tag DataObjects can be created

String Tags

class BlogPost extends DataObject {
	static $db = array(
		'Tags' => 'Text'
	);
}
$field = new StringTagField(
	'BlogTags', 'Blog Tags', array('one', 'two'), explode(',', $post->Tags)
);

$field->setShouldLazyLoad(true); // tags should be lazy loaded

About

SilverStripe module for editing tags (both in the CMS and other forms)

http://silverstripe.org/tag-field-module

License:BSD 2-Clause "Simplified" License


Languages

Language:JavaScript 86.7%Language:CSS 6.6%Language:PHP 6.6%Language:Scheme 0.1%