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, Ed, biapar, Willr, Ingo, swaiba

multiple images on all pages

Go to End

3 Posts   811 Views


Community Member, 175 Posts

18 February 2012 at 3:50am


my Page.php:

public static $has_many = array(
	    'Slides' => 'MyImage'


$slides = new MultipleImageUploadField('Slides', 'Slides');
$fields->addFieldToTab("Root.Content.Slider", $slides); 


class MyImage extends Image {

    static $has_one = array (
	'Page' => 'Page'

so, with this I only cann a image to 1 page. If I want add an image also to an other Page it dont work, I cant choose it in uploadify window, its disabled.


class MyImage extends Image {

    static $has_many = array (
	'Pages' => 'Page'

also dont work. If I do this, it dont work any more.

How to solve this issue?


Forum Moderator, 1307 Posts

18 February 2012 at 8:58am

I don't quite get what you're doing, but having two objects relate 'has_many' to each other won't work. Opposite every $has_many there needs to be a $has_one that holds the ID

The alternative is to do a $many_many / $belongs_many_many relation, where a new table will be created to link the two


Community Member, 539 Posts

21 February 2012 at 12:05am

I am not sure if this is what you mean, but if you want attached images to appear on all pages, but only be attached to one (say the homepage), then you can use the Page() controller to find your page and access its data model. More info is here:

You would use this by adding something like this to your template:

<%  control Page(home) %><% control Slides %><img src="$URL" /><% end_control %><% end_control %>

That what you are after?