for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Class RecentBlogPostsBlock
*/
class RecentBlogPostsBlock extends Block
{
* @var string
private static $singular_name = 'Recent Blog Posts Block';
private static $plural_name = 'Recent Blog Posts Blocks';
* @var array
private static $db = array(
'Limit' => 'Int',
);
private static $has_one = array(
'Blog' => 'Blog',
private static $defaults = array(
'Limit' => 3,
* @return FieldList
public function getCMSFields()
$fields = parent::getCMSFields();
$fields->addFieldsToTab('Root.Main', array(
NumericField::create('Limit'),
));
if (class_exists('Blog')) {
$fields->addFieldToTab(
'Root.Main',
DropdownField::create('BlogID', 'Featured Blog', Blog::get()->map())
->setEmptyString('')
}
return $fields;
* @param null $member
* @return bool
public function canCreate($member = null)
if (!class_exists('Blog')) {
return false;
return parent::canCreate();
public function canView($member = null)
return parent::canView();