Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » has_many editor

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2
Go to End
Author Topic: 6727 Views
  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: has_many editor Link to this post

    > 1) Is it easy to get rid of the checkboxes (as I am filtering the source they are always checked)? Maybe subclass and override the function?
    other way around, use the parentclass ComplexTableField instead if you don't need the relation-setting through checkboxes

    > 2) I'd like to show values from the Image class in the table somehow (e.g. filename).
    you can show any properties that can be accessed on the normal object (or more with setCustomQuery())

    > 3) The ImageField control seems to require that the record is added before the image can be selected. This is a pain because you have to add a PortfolioImage and then edit it to choose an image.
    thats by design, nothing you can easily change without rebuilding the ImageField, as its using iframes for upload. i agree that usability could be better in this use-case...

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: has_many editor Link to this post

    Hi Jam,

    Did you get these things fixed in the meantime ? Working on a little app. which needs the same kind of functionalities.

    Thanks.....

    >1) Is it easy to get rid of the checkboxes (as I am filtering the source they are always >checked)? Maybe subclass and override the function?

    >3) The ImageField control seems to require that the record is added before the image can be >selected. This is a pain because you have to add a PortfolioImage and then edit it to choose >an image.

  • jam13
    Avatar
    121 Posts

    Re: has_many editor Link to this post

    No - not really. I still haven't found a satisfactory way of attaching multiple images to a page as none of the CMS controls are really designed for it.

    The best solution I've found so far is to create folders of images and then link a page to a folder, although this doesn't allow much control of image order. Here's the (simplified) code for a "Gallery Page" that we did for http://www.peterpetrou.com/

    class GalleryPage extends Page {
    static $has_one = array(
    'Image' => 'Image'
    );
    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Content.Images', new ImageField('Image','Main Image'));
    return $fields;
    }
    }

    class GalleryPage_Controller extends Page_Controller {
    function Images() {
    $imageFolder = $this->Image()->ParentID;
    $images = DataObject::get("File", "ParentID = '$imageFolder'");
    return $images;
    }
    }

    Each page has_one primary image, and all the other images that are in the same folder as the primary image are available using the Images function.

    This idea was blatantly stolen from the Gallery module ;)

  • Garrett
    Avatar
    Community Member
    245 Posts

    Re: has_many editor Link to this post

    Hi,

    I copied your code-- thanks A LOT for that! I've been havnig a heck of a time trying to do the same thing.

    My Images tab is showing up nicely, my popup's got the right fields, I can enter the title and upload the image and all that. However, one small problem:

    After I click SAVE and close the popup, I see that it does not appear on the list, which I assume means it has not been saved to the Database?

    What could I be doing wrong here?

    Thanks,
    Garrett

  • jam13
    Avatar
    121 Posts

    Re: has_many editor Link to this post

    Did you db/build?flush=1

  • Garrett
    Avatar
    Community Member
    245 Posts

    Re: has_many editor Link to this post

    I did, I did, yes.... You know what it was? It was this line:

    "PortFolioID = {$this->ID}"

    Mine needed to be "ProjectPageID = {$this->ID}".

    Thanks! Image gallery is rocking now!

    //Garrett

  • banal
    Avatar
    Community Member
    901 Posts

    Re: has_many editor Link to this post

    Hi.
    I developed a cms extension that allows you to attach multiple files/images to a Page. You seem to have resolved your problem, but maybe this could still be of interest for you:
    http://www.silverstripe.com/extending-hacking-silverstripe-forum/flat/134180

    Cheers

    6727 Views
Page: 1 2
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.