silverstripe-blog/model/BlogTag.php

48 lines
919 B
PHP
Raw Normal View History

2013-07-21 12:23:35 +02:00
<?php
/**
* A blog tag for keyword descriptions of a Blog post
*
* @package silverstripe
* @subpackage blog
*
* @author Michael Strong <github@michaelstrong.co.uk>
2013-07-21 12:23:35 +02:00
**/
class BlogTag extends DataObject {
private static $db = array(
"Title" => "Varchar(255)",
);
private static $has_one = array(
"Blog" => "Blog",
);
2013-08-04 18:38:26 +02:00
private static $belongs_many_many = array(
2013-07-21 12:23:35 +02:00
"BlogPosts" => "BlogPost",
);
2013-08-04 18:38:26 +02:00
private static $extensions = array(
"URLSegmentExtension",
);
2013-08-04 18:38:26 +02:00
public function getCMSFields() {
$fields = new FieldList(
TextField::create("Title", _t("BlogTag.Title", "Title"))
2013-08-04 18:38:26 +02:00
);
$this->extend("updateCMSFields", $fields);
return $fields;
}
/**
* Returns a relative URL for the tag link.
*
* @return string URL
**/
public function getLink() {
return Controller::join_links($this->Blog()->Link(), "tag", $this->URLSegment);
}
2013-07-21 12:23:35 +02:00
}