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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

files won't display on website

Go to End

2 Posts   1118 Views


Community Member, 80 Posts

4 May 2011 at 7:58am

Files, or "Vedlegg" dataobjects do appear in CMS, but they won't show on website..



class Vedlegg extends DataObject
	static $db = array (
		'Navn' => 'Text',
		'Beskrivelse' => 'Text'
	static $has_one = array (
		'Fil' => 'File',
		'VedleggSide' => 'VedleggSide'
	public function getCMSFields_forPopup()
		return new FieldSet(
			new TextField('Navn'),
			new TextareaField('Beskrivelse'),
			new FileIFrameField('Fil')




class VedleggSide extends Page {
	public static $db = array(
	public static $has_one = array(
	static $icon = "images/treeicons/folder";
	function getCMSFields() {
	   $fields = parent::getCMSFields();
	   $manager = new FileDataObjectManager(
			$this, // Controller
			'Vedlegg', // Source name
			'Vedlegg', // Source class
			'Fil', // File name on DataObject
				'Navn' => 'Navn', 
				'Beskrivelse' => 'Beskrivelse'
			), // Headings 
			'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
			// Filter clause
			// Sort clause
			// Join clause
	   return $fields;

class VedleggSide_Controller extends Page_Controller {



<% if Vedlegg %>
<h2>Filer til nedlasting</h2>
<div class="vedlegg">
<% control Vedlegg %>
<li<% if FirstLast %> class="$FirstLast"<% end_if %>><% control Fil %><img src="$icon" width="16" height="16" /><% end_control %>&nbsp; &nbsp;<a href="<% control Fil %>$Link<% end_control %>">$Navn</a>
<% if Beskrivelse %><br />$Beskrivelse<% end_if %></li>
<% end_control %>
<% end_if %>

plz, what I am doing wrong here? thanks!


Forum Moderator, 4102 Posts

4 May 2011 at 10:00am

You forgot your has_many!