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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Different Content Region


Go to End


2 Posts   1414 Views

Avatar
Ryan Lawrence

Community Member, 8 Posts

16 February 2012 at 12:15pm

Hello,
I have this script in mysite/code/home.php

<?php
/**
* Defines the HomePage page type
*/

class Home extends Page {

static $db = array (
'Comingsoon' => Text
);
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new TextAreaField ('Comingsoon','Content'));
return $fields;
}

static $has_one = array(
);
}

class Home_Controller extends Page_Controller {

function LatestBlogEntry($num=3) {
$blogpost = DataObject::get_one("BlogHolder");
return ($blogpost) ? DataObject::get("BlogEntry", "", "Date DESC", "", $num) : false;
}
}

What I am basically trying to do is have a different content region on my homepage what is editable in the CMS. I have called it Comingsoon. All I have done is home.php above and just added a $Comingsoon to my template. This isn't working, I dunno if I have missed a step or the code is just wrong. Please help. (Ignore the blog bit at the bottom)
Thanks Ryan

Avatar
martimiz

Forum Moderator, 1391 Posts

18 February 2012 at 1:11am

Should work... Did you /?flush=1 to refresh the template?