Jump to:

23360 Posts in 18124 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Im making a Holder with 2 children pages

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

Page: 1
Go to End
Author Topic: 834 Views
  • Webdoc
    Avatar
    Community Member
    332 Posts

    Im making a Holder with 2 children pages Link to this post

    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 {

    }

    ?>

  • Willr
    Avatar
    Forum Moderator
    5483 Posts

    Re: Im making a Holder with 2 children pages Link to this post

    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?

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Im making a Holder with 2 children pages Link to this post

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

  • Webdoc
    Avatar
    Community Member
    332 Posts

    Re: Im making a Holder with 2 children pages Link to this post

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

    834 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.