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

/dev/build stalling at php code page


Go to End


4 Posts   1661 Views

Avatar
stew

Community Member, 30 Posts

25 August 2009 at 6:02am

Edited: 25/08/2009 6:03am

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

Community Member, 30 Posts

26 August 2009 at 10:47pm

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

Community Member, 323 Posts

27 August 2009 at 2:05am

Hi!

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

Avatar
stew

Community Member, 30 Posts

27 August 2009 at 3:04am

Edited: 27/08/2009 3:04am

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.