7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Using page with DOM multiple times
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: | 464 Views |
-
Using page with DOM multiple times

23 December 2010 at 7:25am
Hi,
I'm experiencing a problem with Filedom. I created a download class and a dowloadPage. All works fine, but when i create second page in the siteroot with this downloadpage template and when i display the items in the dom, all the downloads show up (also the ones from the first page in the siteroot).
Is there any way to add some kind of filter so that page1 shows only the entries in the dom for page one and page2 shows only the entries from the page2 dom?
this is my code so far:
Download.php
<?php
class Download extends DataObject
{
static $db = array (
'Naam' => 'Text',
'Omschrijving' => 'Text',
);static $has_one = array (
'Bijlage' => 'File',
'DownloadPage' => 'DownloadPage'
);public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Naam'),
new TextareaField('Omschrijving'),
new FileIFrameField('Bijlage')
);
}
}?>
DownloadPage.php
<?php
class DownloadPage extends Page
{
static $has_many = array (
'Bijlagen' => 'Download'
);public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, // Controller
'Bijlagen', // Source name
'Download', // Source class
'Bijlage', // File name on DataObject
array(
'Naam' => 'Name',
'Omschrijving' => 'Description',
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$f->addFieldToTab("Root.Content.Downloads",$manager);
return $f;
}
}
class DownloadPage_Controller extends Page_Controller {function AllDownloads() {
$bijlagen = DataObject::get_one("DownloadPage");
return ($bijlagen) ? DataObject::get("Download","", "", "", "") : false;
}
};?>
-
Re: Using page with DOM multiple times

23 December 2010 at 8:27am Last edited: 23 December 2010 8:32am
Hi Guy,
try:
class DownloadPage_Controller extends Page_Controller {
function AllDownloads() {
return $this->data()->Bijlagen();
}};
$this->data() gets the DataRecord as DataObject and ->Bijlagen() gets the Downloads as DataObjectSet, as you defined in has_many.
Greetings,
Robert
-
Re: Using page with DOM multiple times

23 December 2010 at 9:08am
Hi Rob,
Thanx for the fast reply. Your solution works like a charm!
Fantastic.
-
Re: Using page with DOM multiple times

23 December 2010 at 9:20am
it's not my solution - it's sapphire
Rob
| 464 Views | ||
|
Page:
1
|
Go to Top |


