Jump to:

23472 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Upload-image-editing screw up filemanager

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: 448 Views
  • Bereusei
    Avatar
    Community Member
    94 Posts

    Upload-image-editing screw up filemanager Link to this post

    Hey guys,

    I´m following this little tutorial http://doc.silverstripe.org/framework/en/trunk/reference/uploadfield about extending the uploadfield in SS3.
    Everything works really nice in front- and backend, but if I want to start the filemanager in the backend, I get this crazy error:
    Fatal error: Call to undefined method ProductDetail::setSourceQueryParams() in /Applications/MAMP/htdocs/moebel-luebbering3/framework/model/DataList.php on line 678

    class Product extends DataObject
    {
    ...
    static $many_many = array(
          'ProductDetails' => 'Image'
       );
    ....

    public function getCMSFields()
       {
    ...
    $uploadField = new UploadField('ProductDetails','Bilder');
          $uploadField->setFileEditFields('getCustomFields');
          $uploadField->setFolderName('Uploads/Products/' . $this->Categories()->First()->Title);
          $fields->addFieldToTab("Root.Main", $uploadField);

          return $fields;
    }
    }

    class ProductDetail extends DataExtension
    {
    static $db = array (
    'Text1' => 'Text',
    ...
    );

    private static $belongs_many_many = array (
    'Product' => 'Product'
    );
       
       
       function getCustomFields() {
          $fields = new FieldList();
          $fields->push(new TextField('Text1'));
          ...
          
          return $fields;
       }
    }

    class ProductDetailExtension extends DataExtension {
    private static $belongs_many_many = array('Product' => 'Product');
    }

    _config.php

    Image::add_extension('ProductDetailExtension');
    Image::add_extension('ProductDetail');

    Any idea what´s going on? Did someone follow this tutorial, too?

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: Upload-image-editing screw up filemanager Link to this post

    Hmmm I haven't followed the tutoiral.

    But I'm pretty sure you can drop the second dataextension.

    Both ProductDetail and ProductDetailExtension and trying to add the same relationship belongs_many_many/Product.

    Try removing Image::add_extension('ProductDetailExtension');

  • Bereusei
    Avatar
    Community Member
    94 Posts

    Re: Upload-image-editing screw up filemanager Link to this post

    Thanks for response. I´ve changed some things in the code:

    I´ve changed this:

    static $many_many = array(
    'ProductDetails' => 'Image'
    );


    to this:

    static $many_many = array(
    'ProductDetails' => 'ProductImage'
    );


    and add an ProductImage class:

    class ProductImage extends Image {
       private static $extensions = array(
          'ProductDetail'
       );
    }

    I removed double relationship "belongs_many_many", but the filemanager still doesn´t work right.
    If I click now on the folder "Uploads" in the filemanager, the system throw out internal server error.

    I´m using an "$uploadField->setFolderName" where the system self creates folders. Maybe there is a problem with the permissions.
    I´m checking later the code and permissions.

    448 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.