Skip to content

Instantly share code, notes, and snippets.

@alex-zige
Created March 19, 2012 04:04
Show Gist options
  • Save alex-zige/2094243 to your computer and use it in GitHub Desktop.
Save alex-zige/2094243 to your computer and use it in GitHub Desktop.
silverstripe:homepage-buckets
<?php
class HomePage extends Page{
public static $db = array(
'bucket1_title'=>'Text',
'bucket2_title'=>'Text',
'bucket3_title'=>'Text',
'bucket4_title'=>'Text',
'bucket1_desc'=>'Text',
'bucket2_desc'=>'Text',
'bucket3_desc'=>'Text',
'bucket4_desc'=>'Text',
);
public static $has_one = array(
'bucket1_Image'=>'MyImage',
'bucket2_Image'=>'MyImage',
'bucket3_Image'=>'MyImage',
'bucket4_Image'=>'MyImage',
'bucket1_link'=>'SiteTree',
'bucket2_link'=>'SiteTree',
'bucket3_link'=>'SiteTree',
'bucket4_link'=>'SiteTree',
);
public function getCMSFields(){
$fields=parent::getCMSFields();
$fields->addfieldtotab("Root.Content.Bucket1",new textfield('bucket1_title','bucket1 title'));
$fields->addfieldtotab("Root.Content.Bucket1",new textareafield('bucket1_desc','bucket1 description'));
$fields->addfieldtotab("Root.Content.Bucket1",new ImageField('bucket1_Image','bucket1 image'));
$fields->addFieldToTab("Root.Content.Bucket1", new TreeDropdownField('bucket1_linkID', "Link", "SiteTree"));
$fields->addfieldtotab("Root.Content.Bucket2",new textfield('bucket2_title','bucket2 title'));
$fields->addfieldtotab("Root.Content.Bucket2",new textareafield('bucket2_desc','bucket2 description'));
$fields->addfieldtotab("Root.Content.Bucket2",new ImageField('bucket2_Image','bucket2 image'));
$fields->addFieldToTab("Root.Content.Bucket2", new TreeDropdownField('bucket2_linkID', "Link", "SiteTree"));
$fields->addfieldtotab("Root.Content.Bucket3",new textfield('bucket3_title','bucket3 title'));
$fields->addfieldtotab("Root.Content.Bucket3",new textareafield('bucket3_desc','bucket3 description'));
$fields->addfieldtotab("Root.Content.Bucket3",new ImageField('bucket3_Image','bucket3 image'));
$fields->addFieldToTab("Root.Content.Bucket3", new TreeDropdownField('bucket3_linkID', "Link", "SiteTree"));
$fields->addfieldtotab("Root.Content.Bucket4",new textfield('bucket4_title','bucket4 title'));
$fields->addfieldtotab("Root.Content.Bucket4",new textareafield('bucket4_desc','bucket4 description'));
$fields->addfieldtotab("Root.Content.Bucket4",new ImageField('bucket4_Image','bucket4 image'));
$fields->addFieldToTab("Root.Content.Bucket4", new TreeDropdownField('bucket4_linkID', "Link", "SiteTree"));
return $fields;
}
}
class HomePage_Controller extends Page_Controller {
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* array (
* 'action', // anyone can access this action
* 'action' => true, // same as above
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
* );
* </code>
*
* @var array
*/
public static $allowed_actions = array (
);
public function init() {
parent::init();
// Note: you should use SS template require tags inside your templates
// instead of putting Requirements calls here. However these are
// included so that our older themes still work
//Requirements::themedCSS('layout');
//Requirements::themedCSS('typography');
//Requirements::themedCSS('form');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment