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.


Our old forums are still available as a read-only archive.

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

Get random object


20 Posts   9413 Views


2 September 2008 at 5:23pm (Last edited: 2 September 2008 5:39pm), Community Member, 72 Posts

umm, nope. that would be my problem then. let me make the class and see what happens.


I created a new class/page called ProductsPage, and now I'm getting this error:
FATAL ERROR: Object::__call() Method 'forTemplate' not found in class 'ProductsPage'
At line 199 in /Applications/MAMP/htdocs/

maybe I'm missing something on the class stuff. After some good sleep I'll try again tomorrow.
Thanks for all your help guys.


2 September 2008 at 6:11pm Community Member, 72 Posts

alright, I've been playing around with the get_one and get functions and when I use DataObject::get("ProductsPage", "", ""); it returns all the products, just like it should. then when I use DataObject::get_one('ProductsPage', null, false, 'RAND()'); I get the error that its looking for Object::__call() Method 'forTemplate' yet, Method 'forTemplate' not found in class 'ProductsPage',256. I'm starting to grasp this more and more, but maybe I'm missing the function or class to display the one result I want.

and then again maybe I'm just smoking something.


2 September 2008 at 6:18pm (Last edited: 2 September 2008 6:22pm), Forum Moderator, 921 Posts

forTemplate() usually means you're referencing an object in a template, but it doesn't know how to render it.

This could mean that you're doing something like $RandomObject - when it should be in specific calls to properties on that object such as $RandomObject.Title OR using <% control RandomObject %> to render variables in the scope of that object.


3 September 2008 at 2:33am Community Member, 72 Posts

That was it. I put .Title behind it and it worked perfectly.

Thanks for all the help.