Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » /dev/build stalling at php code page

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

Page: 1
Go to End
Author Topic: 1116 Views
  • stew
    Avatar
    Community Member
    30 Posts

    /dev/build stalling at php code page Link to this post

    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

  • stew
    Avatar
    Community Member
    30 Posts

    Re: /dev/build stalling at php code page Link to this post

    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?

  • Juanitou
    Avatar
    Community Member
    322 Posts

    Re: /dev/build stalling at php code page Link to this post

    Hi!

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

  • stew
    Avatar
    Community Member
    30 Posts

    Re: /dev/build stalling at php code page Link to this post

    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.

    1116 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.