Skip to content

Instantly share code, notes, and snippets.

@sminnee
Created June 18, 2015 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sminnee/eaca6614478073aab8c7 to your computer and use it in GitHub Desktop.
Save sminnee/eaca6614478073aab8c7 to your computer and use it in GitHub Desktop.
Adding a dropdown to a StaffHolder...
<?php
class StaffHolder extends Page
{
//...
public function getCMSFields() {
$fields = parent::getCMSFields();
$blob = new DropdownField(
'EmployeeOfTheMonthID',
'Employee of the month',
$this
->Children()
->filter('ClassName', 'StaffPage')
->sort('Title')
->map('ID', 'Title')
);
$blob->setEmptyString('(Select)');
$fields->addFieldToTab(
'Root.Main',
$blob,
'Content'
);
return $fields;
}
}
// ...
<% if EmployeeOfTheMonth %>
<h2>Employee of the month is
<a href="$EmployeeOfTheMonth.Link">
$EmployeeOfTheMonth.Title
</a>
</h2>
<% end_if %>
<!-- ... rest of file goes here -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment