Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » One object two Image

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: 537 Views
  • Nikolay
    Avatar
    Community Member
    5 Posts

    One object two Image Link to this post

    Hello, i seriously surprised, but i can't made easily two images at one Object (Page)

    Based on tutorial, i add one more image at relation.
    static $has_one = array(
       'PhotoLeft' => 'Image',
       'PhotoRight' => 'Image',
    );

    It`s don't work, but i expect another.
    I guess that the picture is not a "field ". This relation 1-1.
    But strangely it is impossible to set two relation by different fields.

    What's the easiest way to make two (not gallery) pictures in one page?

    tnx, SS newbie

  • Devlin
    Avatar
    Community Member
    186 Posts

    Re: One object two Image Link to this post

    There is a getCMSFields() method in your Page class and you did rebuild the database with "/dev/build/?flush"?

  • Nikolay
    Avatar
    Community Member
    5 Posts

    Re: One object two Image Link to this post

    It`s like

    $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Images", new ImageField('PhotoLeft'));
    $fields->addFieldToTab("Root.Content.Images", new ImageField('PhotoRight'));

    At Images folder i see only one upload form, and empty second field.

  • Devlin
    Avatar
    Community Member
    186 Posts

    Re: One object two Image Link to this post

    If you don't rebuild the database, the result would be a empty field. Turn on dev enviroment for proper error messages in your _config.php with ...

    Director::set_environment_type("dev");


    ... and rebuild the database again.

  • Nikolay
    Avatar
    Community Member
    5 Posts

    Re: One object two Image Link to this post

    Rebuild the database make my happy bg tnx

    I thing i do it many times before, and nothing happens.

    537 Views
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.