API Documentation

Info

Elements are extending Silverstripe DataObjects. Therefore all the methods are inherited.
Read about Dataobject methods in the official Silverstripe documentation.

Main API functions

static array $db

create your datamodel in this array (dont forget to run /dev/build/ after making changes!)

static $db = array(
   "Content" = "Text"
);



function getCMSFields()

lets you overload / overwrite the fields in the cms view

function getCMSFields() {
   return new FieldSet(
      new TextareaField("Content")
   );
}



function forTemplate()

is the function that gets called to render the element. Default behavior is to render the element in the classname template, eg MyTestElement will render in MyTestElement.ss

This behavior can be overwritten by returning whatever you like:

function forTemplate() {
   return $this->Content;
}

Advanced functions

function forCMSTemplate()

some elements require to be rendered different in the CMS view than on the front end. This could be to avoid javascript conflicts or simply to speed up loading.

Unless overwritten, this function returns the value of Element::forTemplate()

function forCMSTemplate() {
   return $this->obj("Content")->escapeXML();
}

function getExtraCMSFields()
overload or overwrite the advanced fields
Site made by dodat