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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

accessing filename through PHP


3 Posts   831 Views

Bruce B

6 November 2009 at 12:56pm Community Member, 145 Posts

I'm attempting to add video to a page using the HTML5 code suggested by Mark Pilgrim. I can upload the video files and can show the video on the page but haven't succeeded in joining the two ends together.
I created a new has-one relationship:
'mp4video' => 'File',
and set up the CMS fields to upload the files.

How do I get the file path in PHP? In the template I can use $mp4video.filename and it shows the correct data but any attempt to get info from $this->mp4video just generates an error message about trying to get the properties of a non-object.

I am currently doing this:
$mp4object = DataObject::get_by_id('File', $this->getField('mp4videoID'));
$mp4path = $mp4object->getField('Filename');

but it seems a roundabout route. Can someone help with what must be a very basic hole in my knowledge?



6 November 2009 at 2:31pm Community Member, 244 Posts


Bruce B

6 November 2009 at 3:12pm Community Member, 145 Posts

I knew it was simple. I just couldn't find an example.

many thanks.