Jump to:

5453 Posts in 1674 Topics by 1198 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Adding Image to Page throws [Warning] Unknown Class from is_subclass_of

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

Page: 1
Go to End
Author Topic: 2242 Views
  • dalesaurus
    Avatar
    Community Member
    283 Posts

    Adding Image to Page throws [Warning] Unknown Class from is_subclass_of Link to this post

    I am following the tutorial and adding an Authors section similar to the Staff page:
    http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-site

    I have created a holder and custom page type under them. The fields build and add correctly in the CMS, however the Image tab iframe has a caller error that doesn't make sense to me. The PHP call is_subclass_of is throwing a warning that "Unknown class passed as parameter".

    This is a bizarre error as the class it is complaining about is finding my AuthorPage class under DataObject. Obviously the AuthorPage class is being included as I can create pages and work with it. Why would the Image type interface be blowing up on this?

    Edit: This has been solved, see the second post

    Code:

    <?php
    /*
    * This is for individual Author entries
    */
    class AuthorPage extends Page {
    static $db = array(
    'Name' => 'Text'
    );

    static $has_one = array(
    'Photo' => 'Image'
    );

    /*
    * Add our custom data bits
    */
    function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Content.Main', new TextField('Name'), 'Content');
    $fields->addFieldToTab("Root.Content.Images", new ImageField('Photo'));

    return $fields;
    }
    }

    class AuthorPage_Controller extends Page_Controller {

    }

    /*
    * Holder for all Author Pages
    */
    class Authors extends Page {
    static $db = array();
    static $has_one = array();
    static $allowed_children = array('AuthorPage');
    }

    class Authors_Controller extends Page_Controller {

    }

    ?>

    Error Trace
    Attached

    Attached Files
  • dalesaurus
    Avatar
    Community Member
    283 Posts

    Re: Adding Image to Page throws [Warning] Unknown Class from is_subclass_of Link to this post

    I figured this out, it was merely me being stupid.

    The way SS works with manifesting it's includes relies on the filename / directory location. I was being lazy and put both the Authors and AuthorPage classes in the same file thinking "its just a plain old require_once somewhere". Wrong!

    If you get this error your file and class name do not match somewhere.

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