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.

Data Model Questions /

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

Child Page wont create


Go to End


1207 Views

Avatar
Dunatron

Community Member, 4 Posts

13 March 2016 at 5:32pm

I am getting this error when i try to make a page type of Module under the HomePage, does anyone know why?

Error at line 1739 of /Applications/MAMP/htdocs/tron-sites/onboard/framework/model/DataObject.php

// HomePage
class HomePage extends Page
{
private static $has_many = array(
'ModulePages' => 'ModulePage',
'HomeSlides' => 'HomeSlides',
'ComingSoon' => 'ComingSoon'
);

private static $allowed_children = array(
'ModulePage',
);

//Getting CMS Fields For our Home slides DataObject
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.HomeSlides', GridField::create(
'HomeSlides',
'Slides On This Page',
$this->HomeSlides(),
GridFieldConfig_RecordEditor::create()
));
$fields->addFieldToTab('Root.ComingSoon', GridField::create(
'ComingSoon',
'Modules Coming Soon',
$this->ComingSoon(),
GridFieldConfig_RecordEditor::create()
));
return $fields;
}

}

class HomePage_Controller extends Page_Controller
{
public function init()
{
//Pull in parent properties for controller e.g css & js assets
parent::init();
Requirements::css($this->ThemeDir().'/css/homepage.css');
}

// Return all Members(use this on template to loop client logos)
function pullMembers(){
$members = DataObject::get('Member');
return $members;
}

}

// ModulePage
<?php
/**
* Created by PhpStorm.
* User: Heath
* Date: 6/01/16
* Time: 4:47 PM.
*/
class ModulePage extends Page
{
private static $db = array(
'iconClass' => 'Text',
);

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

private static $has_many = array(
'ModuleVideos' => 'ModuleVideo',
'ModuleScreenshots' => 'ModuleScreenshot'
);

private static $can_be_root = false;

public function getCMSFields()
{
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Main', TextField::create('iconClass', 'glyphicon class e.g glyphicon-home'), 'Content');

//MAIN ASSETS ADDED TO CMS
$fields->addFieldToTab('Root.Videos', GridField::create(
'Video',
'Videos on this page',
$this->ModuleVideos(),
GridFieldConfig_RecordEditor::create()
));

//Add Screenshot tutorials create tab to module page
//MAIN ASSETS ADDED TO CMS
$fields->addFieldToTab('Root.Screenshots', GridField::create(
'Screenshots',
'Screenshots for this Module',
$this->ModuleScreenshots(),
GridFieldConfig_RecordEditor::create()
));

return $fields;
}
}

class ModulePage_Controller extends Page_Controller
{
public function init()
{
//Pull in parent properties for controller e.g css & js assets
parent::init();
Requirements::css($this->ThemeDir().'/css/module-page.css');
}

/**
* @return string
*/
public function getScriptName()
{
//return 'job-details.js';
}

/**
* @return string
*/
public function getStyleName()
{
return 'module-page.css';
}

}