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

Can't display sitetree in admin panel


Go to End


2 Posts   1336 Views

Avatar
kobernicus

Community Member, 1 Post

14 April 2015 at 1:44am

I'm programming a webshop and so I added 3 new pagetypes. Since I've build my database with /dev/build it ain't possible for me to view my sitetree in the admin panel. I can visite my site normally, and the rest in the admin panel like security works. I have inserted a new tab within my pagetype but that doesn't show either.

When I try to load the page type a box is displayed within the text: Warning at line 2591 of /srv/www/htdocs/website/cms/code/model/SiteTree.php.

This is the source code of ProductPage.php:
class ProductPage extends Page {
private static $db = array(
'Name' => 'Varchar(30)',
'Price' => 'Double',
'Description' => 'Text'
);
private static $has_one = array('Photo' => 'Image' );
private static $many_many = array( 'Categories' => 'ProductCategory' );
private static $can_be_root = false;

public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', TextField::create('Name','Productname:'), 'Content');
$fields->addFieldToTab('Root.Main', NumericField::create('Price','Productprice:'), 'Content');
$fields->addFieldToTab('Root.Main', TextareaField::create('Description','Productdescription:'), 'Content');
$fields->addFieldToTab('Root.Attachments', $photo = UploadField::create('Photo'));
$photo->getValidator()->setAllowedExtensions(array('png','jpg','jpeg'));
$photo->setFolderName('product-photos');
$fields->addFieldToTab('Root.Categories', CheckboxSetField::create(
'Categories',
'Selected categories',
$this->Parent()->Categories()->map('ID', 'Title')
));
return $fields;
}

public function CategoriesList() {
if ($this->Categories()->exists()) {
return implode(', ', $this->Categories()->column('Title'));
}
}

This is the source code of ProductHolder:
class ProductHolder extends Page {
private static $allowed_children = 'ProductPage';
private static $has_many = array(
'Categories' => 'ProductCategory'
);

public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Categories', GridField::create(
'Categories',
'Article categories',
$this->Categories(),
GridFieldConfig_RecordEditor::create()
));
}
}

The controllers of both classes are also included in the files, but there empty so that's why I haven't included them.

I hope you guys can help me :)
Thank you!

Avatar
Pyromanik

Community Member, 419 Posts

14 April 2015 at 2:02am

You have a syntax (or some other kind of) error in getCMSFields.