Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Set Default Value for HTMLEditor field + Rotate per day

Go to End

3 Posts   981 Views


Community Member, 28 Posts

14 May 2013 at 6:30am


I am working on a homepage template where a default value should be set when HTMLEditor field X is empty or when a day is passed and the HTMLEditor field X is not filled out with a new value.

I want to update the homepage every day with a daily menu. But it might occur that I forget to set the menu and because the daily menu changes every day I want to replace the menu with the opening times of the restaurant.

I am no php specialist so any help with this is appreciated. What do I need to alter to achieve this?

class HomePage extends Page {

static $db = array(
'Sidetext' => 'HTMLText'

public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new HTMLEditorField('Sidetext'), 'Content');

return $fields;
class HomePage_Controller extends Page_Controller {

Thank you in advance,



Community Member, 254 Posts

15 May 2013 at 11:56am

Hi Wezzlee,
this might be a challenging requirement.

There is a Object called DailyTask you can extend to add daily tasks to. But this will also require that you set up a cron task to execute all daily tasks.

The other way, which ain't so elegant is to have an onBeforePublish method on your model. Which will check each time the page is loaded if the text has updated.

Those are two places to start looking.


Community Member, 28 Posts

16 May 2013 at 6:42am

Thank you Bambii7.

I will do some investigation with this information.