7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Problem with SiteTree in DOM
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: | 1562 Views |
-
Problem with SiteTree in DOM

23 October 2010 at 5:14pm Last edited: 23 October 2010 5:14pm
Can anyone see if maybe I am missing something. My luck a comma!
I get the following error when trying to include a site treet drop down in my File DOM.
[User Error] Uncaught Exception: Object->__call(): the method 'fortemplate' does not exist on 'SiteTree'
GET /admin
Line 724 in /home/content/28/4118128/html/sapphire/core/Object.phpTHANKS!
GOLDSPONSOR.PHP
<?php
class GoldSponsor extends DataObject
{
static $db = array (
'CompanyName' => 'Text',
'CompanyWebAddress' => 'Text'
);static $has_one = array (
'Attachment' => 'File',
'GoldSponsorPage' => 'GoldSponsorPage'
'GoldRelatedArticle' => 'SiteTree',
);public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('CompanyName'),
new TextField('CompanyWebAddress'),
new SimpleTreeDropdownField('GoldRelatedArticleID', "Related Page", 'SiteTree'),
new FileIFrameField('Attachment')
);
}
}?>
GOLDSPONSORPAGE.PHP
<?php
class GoldSponsorPage extends RightNav
{
static $has_many = array (
'GoldSponsors' => 'GoldSponsor'
);public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, // Controller
'GoldSponsors', // Source name
'GoldSponsor', // Source class
'Attachment', // File name on DataObject
array(
'CompanyName' => 'CompanyName',
'CompanyWebAddress' => 'CompanyWebAddress',
'GoldRelatedArticle' => 'GoldRelatedArticle'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$f->addFieldToTab("Root.Content.GoldSponsor",$manager);
return $f;
}
}class GoldSponsorPage_Controller extends RightNav_Controller {
}
?>
-
Re: Problem with SiteTree in DOM

24 October 2010 at 4:04am
This happens in the CMS? That looks like the type of error you'd get on the frontend.
Is there anymore of that trace?
---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com -
Re: Problem with SiteTree in DOM

24 October 2010 at 9:53am Last edited: 24 October 2010 9:53am
It happens when I try to load the front end page, or after I create an item in the cms i get the "page says" gray box and it dumps the following message. It keeps mentioning the blog entry too, which is weird.
The page at XXXXXX.com says:ERROR [User Error]: Uncaught Exception: Object->__call(): the method 'fortemplate' does not exist on 'BlogEntry'
IN POST /admin/getitem?ID=176&ajax=1
Line 724 in /home/content/28/4118128/html/sapphire/core/Object.phpSource
======
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
=====
<ul>Object->__call(forTemplate,Array)
line 447 of ViewableData.phpBlogEntry->forTemplate()
line 447 of ViewableData.phpViewableData->XML_val(PlatinumRelatedArticle)
line 1341 of TableListField.phpTableListField_Item->Fields()
line 603 of DataObjectManager.phpDataObjectManager_Item->Fields()
line 369 of ViewableData.phpViewableData->obj(Fields)
line 590 of .cache.home.content.28.4118128.html.dataobject_manager.templates.FileDataObjectManager.ssinclude(/home/content/28/4118128/html/silverstripe-cache/.cache.home.content.28.4118128.html.dataobject_manager.templates.FileDataObjectManager.ss)
line 420 of SSViewer.phpSSViewer->process(FileDataObjectManager)
line 342 of ViewableData.phpViewableData->renderWith(FileDataObjectManager)
line 275 of ComplexTableField.phpComplexTableField->FieldHolder()
line 266 of DataObjectManager.phpDataObjectManager->FieldHolder()
line 369 of ViewableData.phpViewableData->obj(FieldHolder,,,1)
line 446 of ViewableData.phpViewableData->XML_val(FieldHolder,,1)
line 73 of .cache.home.content.28.4118128.html.sapphire.templates.TabSetFieldHolder.ssinclude(/home/content/28/4118128/html/silverstripe-cache/.cache.home.content.28.4118128.html.sapphire.templates.TabSetFieldHolder.ss)
line 420 of SSViewer.phpSSViewer->process(TabSet)
line 342 of ViewableData.phpViewableData->renderWith(TabSetFieldHolder)
line 80 of TabSet.phpTabSet->FieldHolder()
line 369 of ViewableData.phpViewableData->obj(FieldHolder,,,1)
line 446 of ViewableData.phpViewableData->XML_val(FieldHolder,,1)
line 58 of .cache.home.content.28.4118128.html.sapphire.templates.TabSetFieldHolder.ssinclude(/home/content/28/4118128/html/silverstripe-cache/.cache.home.content.28.4118128.html.sapphire.templates.TabSetFieldHolder.ss)
line 420 of SSViewer.phpSSViewer->process(TabSet)
line 342 of ViewableData.phpViewableData->renderWith(TabSetFieldHolder)
line 80 of TabSet.phpTabSet->FieldHolder()
line 369 of ViewableData.phpViewableData->obj(FieldHolder,,,1)
line 446 of ViewableData.phpViewableData->XML_val(FieldHolder,,1)
line 77 of .cache.home.content.28.4118128.html.sapphire.templates.Includes.Form.ssinclude(/home/content/28/4118128/html/silverstripe-cache/.cache.home.content.28.4118128.html.sapphire.templates.Includes.Form.ss)
line 420 of SSViewer.phpSSViewer->process(Form)
line 342 of ViewableData.phpViewableData->renderWith(Array)
line 1085 of Form.phpForm->forTemplate()
line 1112 of Form.phpForm->formHtmlContent()
line 384 of LeftAndMain.phpLeftAndMain->getitem(SS_HTTPRequest)
line 193 of Controller.phpController->handleAction(SS_HTTPRequest)
line 137 of RequestHandler.phpRequestHandler->handleRequest(SS_HTTPRequest)
line 147 of Controller.phpController->handleRequest(SS_HTTPRequest)
line 281 of Director.phpDirector::handleRequest(SS_HTTPRequest,Session)
line 124 of Director.phpDirector::direct(/admin/getitem)
line 127 of main.php</ul>
[/code/
-
Re: Problem with SiteTree in DOM

24 October 2010 at 11:10am
You're probably trying to render a SiteTree object on the template?? Like this, maybe?
$GoldRelatedArticle
You can't do that, of course, because there's nothing to render. $GoldRelatedArticle.Title will give you something, but not the object itself.
---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com -
Re: Problem with SiteTree in DOM

24 October 2010 at 11:51am
The weird thing is, I haven't even created a layout page yet for it. Havn't even got that far! Is the code i am using look fine? Maybe need to just start from scratch again!
-
Re: Problem with SiteTree in DOM

24 October 2010 at 12:45pm
It's in your headings array:
'GoldRelatedArticle' => 'GoldRelatedArticle'
You can't render $GoldRelatedArticle as a column in the table. You need to choose what field you want to show. Try this:
public function getGoldTitle() {
if($page = $this->GoldRelatedArticle()) {
return $page->Title;
}
return false;
}and change your headings array to use:
'GoldTitle' => 'Related article title'
---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com -
Re: Problem with SiteTree in DOM

25 January 2012 at 10:48pm Last edited: 25 January 2012 10:49pm
Apologies for the bump. I'm just curious about how you can make this work. I've got a similar issue going on, but it's a low-priority, really.
I'm just curious about the principle of controlling the content of DOM columns using functions.
Regarding the example that UC wrote in the above post: how does it know to refer to the getGoldTitle()function based on its array key ('GoldTitle')?
I've tried adding a function to the page's controller that always returns "foo", but I can't even get that to work.I'm hoping someone can help me figure this one out. Thanks in advance.
-
Re: Problem with SiteTree in DOM

8 May 2012 at 5:43am
Well, you basically tell the DOM in the 4th parameter with an array which method in the DataObject to use to display in the overview.
For example:new DataObjectManager(
$this,
'TeaserImages',
'TeaserImage',
array(
'Image' => 'Bild',
'getSelectedSiteTitle' => 'verlinkte Seite',
),
'getCMSFields_forPopup'
)will call TeaserImage->getSelectedSiteTitle() for displaying a value in the second column of the DOM overview. Within the DataObject inherited class put the method and access the DataObjects values (example is for a SiteTree):
public function getSelectedSiteTitle() {
return $this->obj('LinkTo')->Title;
}
| 1562 Views | ||
|
Page:
1
|
Go to Top |


