silverstripe-blog/code/widgets/BlogCategoriesWIdget.php

43 lines
862 B
PHP
Raw Normal View History

2013-08-04 18:38:26 +02:00
<?php
2013-10-10 00:09:28 +02:00
if(class_exists("Widget")) {
2013-08-04 18:38:26 +02:00
2013-10-10 00:09:28 +02:00
class BlogCategoriesWidget extends Widget {
private static $title = "Categories";
2013-08-04 18:38:26 +02:00
2013-10-10 00:09:28 +02:00
private static $cmsTitle = "Blog Categories";
2013-08-04 18:38:26 +02:00
2013-10-10 00:09:28 +02:00
private static $description = "Displays a list of blog categories.";
2013-08-04 18:38:26 +02:00
2013-10-10 00:09:28 +02:00
private static $db = array();
2013-08-04 18:38:26 +02:00
2013-10-10 00:09:28 +02:00
private static $has_one = array(
"Blog" => "Blog",
);
public function getCMSFields() {
$fields = FieldList::create();
$fields->push(
DropdownField::create("BlogID", _t("BlogCategoriesWidget.Blog", "Blog"), Blog::get()->map())
);
$this->extend("updateCMSFields", $fields);
2013-10-10 00:09:28 +02:00
return $fields;
}
2013-08-04 18:38:26 +02:00
2013-10-10 00:09:28 +02:00
public function getCategories() {
$blog = $this->Blog();
if($blog) {
return $blog->Categories();
}
return array();
2013-08-04 18:38:26 +02:00
}
2013-10-10 00:09:28 +02:00
2013-08-04 18:38:26 +02:00
}
2013-10-10 00:09:28 +02:00
class BlogCategoriesWidget_Controller extends Widget_Controller {
}
2013-08-04 18:38:26 +02:00
2013-10-10 00:09:28 +02:00
}