Go to file
Christopher Pitt 4f86c021cf Merge pull request #40 from 3Dgoo/feature/readme-fixes
Little fixes to read me example code.
2015-09-08 14:17:09 +12:00
code Fixed issue where empty keywords field would be passed to array functions as a string. 2015-08-27 11:25:58 +10:00
css Correct close button image 2015-04-24 04:33:07 +12:00
js BUGFIX: Allow use on frontend 2015-07-07 13:27:30 +02:00
templates Moved source code 2015-04-14 13:15:28 +12:00
tests Stabilized API 2015-05-22 15:22:13 +12:00
.gitignore Moved source code 2015-04-14 13:15:28 +12:00
.travis.yml Move to new travis containerised infrastructure 2015-07-20 16:07:46 +01:00
LICENCE Added licence file 2015-05-25 08:50:29 +12:00
README.md Little fixes to read me example code. 2015-09-08 11:42:28 +09:30
_config.php Moved source code 2015-04-14 13:15:28 +12:00
composer.json Removed version alias 2015-05-25 09:03:49 +12:00

README.md

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

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

	private static $belongs_many_many = array(
		'BlogPosts' => 'BlogPost'
	);
}
$field = TagField::create(
	'BlogTags',
	'Blog Tags',
	BlogTag::get(),
	$this->BlogTags()
)
	->setShouldLazyLoad(true) // tags should be lazy loaded
	->setCanCreate(true);     // new tag DataObjects can be created

String Tags

class BlogPost extends DataObject {
	private static $db = array(
		'Tags' => 'Text'
	);
}
$field = StringTagField::create(
	'Tags',
	'Tags',
	array('one', 'two'),
	explode(',', $this->Tags)
);

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