7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » [Solved] DataObjectManager Problem on front-end template only
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1732 Views |
-
[Solved] DataObjectManager Problem on front-end template only

1 June 2010 at 3:16am Last edited: 1 June 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=StageLine 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 /**
TraceObject->__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.phpGalleryPic.php:
<?php
class Gallery_Image extends Image { // This class can go inside the same file as Page.phpfunction 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?
-
Re: [Solved] DataObjectManager Problem on front-end template only

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
-
Re: [Solved] DataObjectManager Problem on front-end template only

1 June 2010 at 4:28am
Aha! Thanks a mil Ciaran
| 1732 Views | ||
|
Page:
1
|
Go to Top |


