Skip to content

Instantly share code, notes, and snippets.

@rotassator
Last active February 13, 2017 22:43
Show Gist options
  • Save rotassator/9cbf760020bb0067f3c4 to your computer and use it in GitHub Desktop.
Save rotassator/9cbf760020bb0067f3c4 to your computer and use it in GitHub Desktop.
SilverStripe: Page model example
<?php
/** PageExample */
/**
* PageExample
*
* Example description.
*/
class PageExample extends Page
{
/** @var array Database fields */
private static $db = array();
/** @var array Related models with one related item */
private static $has_one = array();
/** @var array Related models with many related items */
private static $has_many = array();
/** @var array Related models with many-many relationship */
/**
* Overload CMS admin field list
* @return FieldList Customised CMS tab set
* @codeCoverageIgnore
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();
return $fields;
}
}
/**
* PageExample Controller
*
* Shared processing for all things based on PageExample.
*/
class PageExample_Controller extends Page_Controller
{
/** @var array List of actions that can be accessed via a request */
private static $allowed_actions = array();
/**
* Handle incoming URLs
*
* Handle incoming URLs according to the following patterns:
* ```
* ~/ - Default action
* ```
* @var array List of URL handlers
*/
private static $url_handlers = array();
/**
* Initialise PageExample object
*/
public function init()
{
parent::init();
}
/**
* Main page
* @return Page Rendered detail page
*/
public function index()
{
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment