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.

Customising the CMS

/dev/build stalling at php code page


Reply

4 Posts   1186 Views

Avatar
stew

25 August 2009 at 6:02am (Last edited: 25 August 2009 6:03am), Community Member, 30 Posts

Hey guys,

I have almost finished my first SilverStripe site for a client, however their final request has left me with a major headache.

I have been asked to add in a few extra fields into a particular page type... it already has 2 custom fields which I added in without any problems, however adding these new fields is leaving me with major problems - visiting /dev/build?=flush results in it stalling at the page before the one which is getting these new fields and visiting the main page results in a blank screen.

This is what I have in OurDogsPage.php:

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

class OurDogsPage extends Page {
static $db = array(
      'DogInfo' => 'HTMLText'
      'DogInfoFather' => 'Text'
      'DogInfoMother' => 'Text'
);

static $has_one = array(
      'DogPhoto' => 'Image'
      'DogPhotoFather' => 'Image'
      'DogPhotoMother' => 'Image'
);

   
   // Add this method under your static $db array bit.
   function getCMSFields() {
   $fields = parent::getCMSFields();
   $fields->addFieldToTab('Root.Content.Main', new ImageField('DogPhoto', 'Main Dog Photograph'));
   $fields->addFieldToTab('Root.Content.Main', new HTMLEditorField('DogInfo', 'Dog Info'));
   $fields->addFieldToTab('Root.Content.Lineage', new ImageField('DogPhotoFather', 'Dogs Father Photo'));
   $fields->addFieldToTab('Root.Content.Lineage', new TextField('DogInfoFather', 'Dogs Father Name'));
   $fields->addFieldToTab('Root.Content.Lineage', new ImageField('DogPhotoMother', 'Dogs Mother Photo'));
   $fields->addFieldToTab('Root.Content.Lineage', new TextField('DogInfoMother', 'Dogs Mother Name'));

   return $fields;
   
   }

}

class OurDogsPage_Controller extends Page_Controller {

   
}
?>

The DogInfo and DogPhoto fields work fine. When I take out the DogInfoFather/Mother and DogPhotoFather/Mother code in the array at the start /dev/build and the site load fine (but without the fields obviously)

For the record my OursDogsHolder.php file simply contains:

<?php

class OurDogsHolder extends Page {
static $db = array(
);
static $has_one = array(
);
   
static $allowed_children = array('OurDogsPage');
}

class OurDogsHolder_Controller extends Page_Controller {
   
}

?>

I'm completely stumped as to where I have gone wrong and have worked through the tutorials sample code a half dozen times trying to find the mistake but I have no idea where it is.

Thanks for your help,

Stewart

Avatar
stew

26 August 2009 at 10:47pm Community Member, 30 Posts

I've done some more testing and if I remove the 'DogInfo' => 'HTMLText' and put in a date field it will build properly but obviously that's of no use to me, it seems adding a second field to the array breaks the site...

any help? please?

Avatar
Juanitou

27 August 2009 at 2:05am Community Member, 323 Posts

Hi!

Your syntax is wrong: array members have to be separated with commas.

Avatar
stew

27 August 2009 at 3:04am (Last edited: 27 August 2009 3:04am), Community Member, 30 Posts

Wow I feel stupid. lol. I think it'd be worth including that in one of the examples of Tutorial 2.

Thanks for your help Juanitou, much appreciated.