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.

General Questions

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

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

Im making a Holder with 2 children pages


Reply

4 Posts   944 Views

Avatar
Webdoc

14 February 2010 at 9:47am Community Member, 332 Posts

But it gives error
in page i need field for height, weight, picture, video link, and the name
have made them using article holder and article page tutorial but something goed wrong.

The pages are called : ElevantPage.php , DigisilmPage.php
and holder name is: KaameraHolder.php

Codes Are

Digisilmpage.php :
<?php
/**
* Defines the ElevantPage page type
*/
class DigisilmPage extends Page {
static $db = array(
   'Video' => 'Text',
   'Pealkiri' => 'Text',
   'Photo' => 'Image',
   'Pikkus' => 'Text',
   'Korgus' => 'Text'
);
static $has_one = array(
);
}

class DigisilmPage_Controller extends Page_Controller {

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

   $fields->addFieldToTab('Root.Content.Main', new TextField('Video'), 'Content');
   $fields->addFieldToTab('Root.Content.Main', new TextField('Pealkiri'), 'Content');
   $fields->addFieldToTab('Root.Content.Main', new ImageField('Photo'), "Content");
   $fields->addFieldToTab('Root.Content.Main', new TextField('Pikkus'), 'Content');
   $fields->addFieldToTab('Root.Content.Main', new TextField('Korgus'), 'Content');
   
   return $fields;
}

}

?>

ElevantPage.php:
<?php
/**
* Defines the ElevantPage page type
*/
class ElevantPage extends Page {
static $db = array(
   'Video' => 'Text',
   'Pealkiri' => 'Text',
   'Photo' => 'Image',
   'Pikkus' => 'Text',
   'VideoKorgus' => 'Text'
   
);
static $has_one = array(
);
}

class ElevantPage_Controller extends Page_Controller {

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

   $fields->addFieldToTab('Root.Content.Main', new TextField('Video'), 'Content');
   $fields->addFieldToTab('Root.Content.Main', new TextField('Pealkiri'), 'Content');
   $fields->addFieldToTab('Root.Content.Main', new ImageField('Photo'), 'Content');
   $fields->addFieldToTab('Root.Content.Main', new TextField('Pikkus'), 'Content');
   $fields->addFieldToTab('Root.Content.Main', new TextField('Korgus'), 'Content');
   
   return $fields;
}

}

?>

And the holder page is

<?php
/**
* Defines the ArticleHolder page type
*/
class KaameraHolder extends Page {

static $allowed_children = array("DigisilmPage", "ElevantPage");
}

class KaameraHolder_Controller extends Page_Controller {

}

?>

Avatar
Willr

14 February 2010 at 2:04pm Forum Moderator, 5511 Posts

Your getCMSFields should be in the model class, not the controller. Thats 1 issue but it shouldn't throw an error. Put your site in devmode and post the actual error message you get it, it'll be quite helpful?

Avatar
Webdoc

14 February 2010 at 5:11pm Community Member, 332 Posts

found the second problem also it was in db the photo it needed to be in has one.

Avatar
Webdoc

14 February 2010 at 7:48pm Community Member, 332 Posts

Is there a way to add in the code dataobject htmlfield where i can insert the embed code.