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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

[Solved] DataObjectManager Problem on front-end template only


Go to End


3 Posts   3103 Views

Avatar
neilcreagh

Community Member, 136 Posts

1 June 2010 at 3:16am

Edited: 01/06/2010 6:19am

Hi UncleCheese (or anyone who can help),

I'm running Silverstripe 2.4, does the DataObjectManager work with this latest version? I have the DataObjectManager and SWFUpload modules installed. I had all sorts of trouble with the Gallery Module so I scrapped it in favour of just creating a simple Gallery Page, with just one gallery of images per page.

All is working perfectly in the back-end admin area, but there is an error displaying the front-end template:

- - - - - - - - - - - -
[User Error] Uncaught Exception: Object->__call(): the method 'handlerequest' does not exist on 'GalleryPage'
GET /about-us/visitor-drawings/?stage=Stage

Line 724 in /home/nlm/leprechaunmuseum.ie/sapphire/core/Object.php

Source

715
716 default :
717 throw new Exception (
718 "Object->__call(): extra method $method is invalid on $this->class:" . var_export($config, true)
719 );
720 }
721 } else {
722 // Please do not change the exception code number below.
723
724 throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);
725 }
726 }
727
728 // -----------------------------------------------------------------------------------------------------------------
729
730 /**
Trace

Object->__call(handleRequest,Array)
GalleryPage->handleRequest(SS_HTTPRequest)
Line 184 of ContentController.php
ContentController->handleRequest(SS_HTTPRequest)
Line 67 of ModelAsController.php
ModelAsController->handleRequest(SS_HTTPRequest)
Line 283 of Director.php
Director::handleRequest(SS_HTTPRequest,Session)
Line 127 of Director.php
Director::direct(/about-us/visitor-drawings/)
Line 127 of main.php

- - - - - - - - - - - - - - -

My code is very straightforward - and seesm to be working perfectly within Silverstripe (I can add Gallery Pages and upload images, sort them etc.)
My two PHP pages in my code folder are GalleryPage.php and GalleryPic.php

GalleryPic.php:
<?php
class Gallery_Image extends Image { // This class can go inside the same file as Page.php

function generateSmallimage($gd) {
return $gd->resizeRatio(170,170);
}

function generateLarger($gd) {
return $gd->resizeRatio(580,580);
}

}

class GalleryPic extends DataObject
{
static $db = array (
'Name' => 'Text'
);

static $has_one = array (
'GalleryImage' => 'Gallery_Image',
'GalleryPage' => 'GalleryPage'
);

public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new ImageField('GalleryImage')
);
}
}

?>

GalleryPage.php:
<?php
class GalleryPage extends Page
{
static $has_many = array (
'GalleryPictures' => 'GalleryPic'
);

public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new ImageDataObjectManager(
$this, // Controller
'GalleryPictures', // Source name
'GalleryPic', // Source class
'GalleryImage', // File name on DataObject
array(
'Name' => 'Name'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$f->addFieldToTab("Root.Content.GalleryImages",$manager);
$f->removeByName("Images");
$f->removeByName("Video");
return $f;

}

static $icon = "themes/nlm/images/treeicons/gallery";

}
?>

I don't think it's a problem with my template because even if I don't add any .ss template for GalleryPage then it should be extending from Page.ss so a regular page template should appear - but this error still appears instead.

Any ideas?

Avatar
ciaranhickey

Community Member, 17 Posts

1 June 2010 at 4:21am

Hi,

You possibly need a Page Controller in your GalleryPage class.

Try adding the following and doing a rebuild:

class GalleryPage_Controller extends Page_Controller {

	public static $allowed_actions = array (
	);

	public function init() {
		parent::init();
	}
	
}

Hope that works!

Ciaran

Avatar
neilcreagh

Community Member, 136 Posts

1 June 2010 at 4:28am

Aha! Thanks a mil Ciaran