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 /

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


Reply


2 Posts   2345 Views

Avatar
dalesaurus

Community Member, 283 Posts

7 August 2009 at 5:37am

Edited: 07/08/2009 7:49am

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
Avatar
dalesaurus

Community Member, 283 Posts

7 August 2009 at 7:48am

Edited: 07/08/2009 7:49am

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.