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.

Customising the CMS /

Displaying Uploaded Images


Reply


2 Posts   812 Views

Avatar
craigm

Community Member, 9 Posts

12 March 2010 at 1:29pm

Edited: 12/03/2010 1:30pm

Hi,

Im pretty new to SilverStripe, so excuse my ignorance but I cant figure out how to access an image ive uploaded via a custom module ive built.

Ive created the custom module and added to it an extra field in the CMS:

$fields->addFieldToTab('Root.Content.Main', new ImageField('Image','Upload Image'), 'Content');

ive also added the Image field to the has_one array:

static $has_one = array('Image' => 'File');

Now how do i call that in the .ss file? Is there a pre built function for loading in an associated image similar to $Content

or do i have to call a custom function that i build in the Controller of my module and return the image through it?

if i have to build it custom, what do i need to write in there? i dont have much of an idea..

Some help would be great.

Cheers!

Craig.

Avatar
craigm

Community Member, 9 Posts

12 March 2010 at 2:26pm

never mind, i just changed the has_one array to:

static $has_one = array('Image' => 'Image');

and called $Image in the .ss file

seems to work fine :)