silverstripe-blog/code/widgets/BlogCategoriesWidget.php
Damian Mooyman 686112aa10 BUG Fix Type field conflict with core Widget field
Type is used for the widget classname
Better scaffolding of formfields
Fix typo in filename
2015-03-06 13:37:37 +13:00

43 lines
859 B
PHP

<?php
if(class_exists("Widget")) {
class BlogCategoriesWidget extends Widget {
private static $title = "Categories";
private static $cmsTitle = "Blog Categories";
private static $description = "Displays a list of blog categories.";
private static $db = array();
private static $has_one = array(
"Blog" => "Blog",
);
public function getCMSFields() {
$this->beforeUpdateCMSFields(function($fields) {
$fields->push(
DropdownField::create("BlogID", _t("BlogCategoriesWidget.Blog", "Blog"), Blog::get()->map())
);
});
return parent::getCMSFields();
}
public function getCategories() {
$blog = $this->Blog();
if($blog) {
return $blog->Categories();
}
return array();
}
}
class BlogCategoriesWidget_Controller extends Widget_Controller {
}
}