Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » multiple images on all pages

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

Page: 1
Go to End
Author Topic: 473 Views
  • danzzz
    Community Member
    175 Posts

    multiple images on all pages Link to this post


    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?

  • martimiz
    Forum Moderator
    1086 Posts

    Re: multiple images on all pages Link to this post

    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

  • Mo
    Community Member
    508 Posts

    Re: multiple images on all pages Link to this post

    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?


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.