<% control Get %> ? Problems with conversion to silverstripe 4 [solved]

Silverstripe 4

Hello all, please for the love of god help me i need help, please help.
With that attractive clingy frustration out of the way, I have this issue.
While trying to get our site working again after the PHP update catastrophe, I upgraded to Silverstripe 4. After a long and hard fight, uphill, I have this one Issue left.

Our homepage used to Get a Footer from trough either the PageController or the ContentController - due to a shabby backup culture the original has been lost. However revised versions worked - here is the code that used to work under silverstripe 2 - 3 ish. (#Hire me)

class Page extends SiteTree {

 private static $db = array (
	'MyTitle' => 'Varchar'
 public function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Main', TextField::create('MyTitle','MyTitle'),'Content');
    return $fields;

private static $has_one = array(
  'Footer' => 'Footer' );

class Page_Controller extends ContentController {

     public function GetFooter(){
            $Footer = DataObject::get_one('Footer');
            return $Footer;
	private static $allowed_actions = array (

	public function init() {


So thats a snippet of the file with the useless stuff removed.

<% control GetFooter%>
<% end_control %>

Now i fixed the old array syntax and put the classes in a common namespace. But its the latter code in the page.ss thats giving me errors. ( Error was: Unknown closed block “control” encountered. Perhaps you are not supposed to close this block, or have mis-spelled it?)

I can only guess that control being used in this way has been deprecated, or maybe changed. OR MAYBE I’M AN IDIOT ! This is maybe most likely in any event.

I can only hope that some good samaritan on this forum can save me from eating my keycaps in frustration.

Thanks in advance !

Edit i should mention that the Footer is a .ss in the layout folder. and works on Its own in the editor - but i have not successfully included with data(yes when moved to include folder) as a footer to the main page.

1 Like

<% control %> is very old syntax, and has been replaced.

In that case you should be able to use <% with GetFooter %>$MyTitle<% end_with %>

You could possibly even use $GetFooter.MyTitle as a one-liner

Just another thought actually. Since you’re on SS4 now, that Page_Controller class quite possibly won’t be called at all. The naming conventions were changed to remove the underscore.

You should find a class called PageController in the code (in its own file) - this is the standard controller class which will be used when handling your Page, so you should move your custom methods into that and get rid of the old class.

1 Like

Would you look at that! I came so close to the solution when i changed it to <% with Footer%> thinking it needed to grab the whole template. Everything’s back to normal, thank you so much, this really brightened my day :grinning: