Skip to content

Instantly share code, notes, and snippets.

@agent44
Created March 18, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agent44/a31f6238a2fd7fd50197 to your computer and use it in GitHub Desktop.
Save agent44/a31f6238a2fd7fd50197 to your computer and use it in GitHub Desktop.
FAQPage...
class FAQPage extends Page
{
private static $allowed_children = array (
'FAQItem'
);
}
class FAQPage_Controller extends Page_Controller
{
}
FAQItem...
class FAQItem extends DataObject
{
private static $db = array (
'Question' => 'Text',
'Answer' => 'Text'
);
public function getCMSFields()
{
$fields = FieldList::create(TabSet::create('Root'));
$fields->addFieldsToTab('Root.Main', array(
TextField::create('Question'),
TextAreaField::create('Answer')
));
return $fields;
}
}
In my FAQPage.ss ...
<% loop $Children %>
<p>$Question</p>
<p>$Answer</p>
<% end_loop %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment