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:

General Questions /

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

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

[Solved] One Photo, Several Pages

Go to End

2 Posts   1004 Views


Community Member, 24 Posts

20 August 2010 at 2:24am

Edited: 23/08/2010 2:18pm

I added a photo to a page with the following method (actually to a Product in the ecommerce module to be more precise):

static $has_one = array(
'Photo' => 'Image'


function getCMSFields($cms) {
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo'));
return $fields;

I have photos in an asset folder. I can only associate each of these photos to only one page, as soon as the photo is used, it becomes unavailable for selection to other pages.

Could someone please help? I suspect it's a one to many type relationship I need to develop, but I am lost at this stage.


Community Member, 24 Posts

23 August 2010 at 2:18pm

I have a solution.

In ecommerce, Product_Image seems to only attach file to an image, by that I mean that if I add a file from a From the File Store, I can only select one image per specific product.

Changing to this in Product php:
public static $has_one = array(
'MyImage' => 'Image',

instead of:

public static $has_one = array(
'MyImage' => 'Product_Image',

solved my issue.