7919 Posts in 1358 Topics by 932 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Displaying Dataobjects in a list on the frontend
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: | 424 Views |
-
Displaying Dataobjects in a list on the frontend

10 October 2011 at 11:28am
Hey guys, Having some trouble with a control block and complextablefield. Likely a n00b question but i'm at the point of wtf
$category in the template will display a list of entries but i want to show all the fields from $category. My first time using the complextablefield, so i'm pretty stuck on whats going wrong here.
cheers for you time
DriverHolder.php
<?php
class DriverHolder extends Page {
static $db = array();
static $has_one = array(
);
static $has_many = array(
'category' => 'category'
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Drivers', new ComplexTableField(
$this,
'Title',
'category',
array('Title' => 'Title', 'Description' => 'Description'),
'getCMSFields_forPopup'
));
return $fields;}
}class DriverHolder_Controller extends Page_Controller {}
?>
DriverHolder.ss
<table>
<th>Driver</th><th>Description</th><th>Download</th>
<% control catagory %>
<tr>
<td>$Title</td>
<td>$Description</td>
<td>$File.URL</td>
</tr>
<% end_control %>
</table> -
Re: Displaying Dataobjects in a list on the frontend

10 October 2011 at 3:25pm
You have a typo in your control block "catagory" - could be the cause?
-
Re: Displaying Dataobjects in a list on the frontend

10 October 2011 at 4:18pm
Yes i did, but i cleaned it up and still not working heres the cleaners version
driver.php
<?php
class driver extends DataObject {static $db = array (
'Title' => 'Text',
'Description' => 'Text'
);
static $has_one = array (
'DriverHolder' => 'DriverHolder',
'File' => 'File'
);
static $has_many = array ();
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push(new TextField('Title', 'Title'));
$fields->push(new TextField('Description', 'Description'));
$fields->push(new FileIFrameField('File', 'File'));
return $fields;
}
}
DriverHolder.php<?php
class DriverHolder extends Page {
static $db = array();static $has_one = array();
static $has_many = array(
'driver' => 'driver'
);static $allowed_children = array('DriverPage');
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.drivers', new ComplexTableField(
$this,
'Title',
'driver',
array('Title' => 'Title'),
'getCMSFields_forPopup'
));
return $fields;
}
}class DriverHolder_Controller extends Page_Controller {}
DriverHolder.ss<table width="100%">
<th>Driver</th><th>Description</th><th>Download</th>
<% control driver %>
<tr>
<td>$Title</td>
<td>$Description</td>
<td><a href="$File.URL">[download]</a></td>
</tr>
<% end_control %>
</table>
| 424 Views | ||
|
Page:
1
|
Go to Top |


