Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Uploaded File Management on a Page

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

Page: 1
Go to End
Author Topic: 428 Views
  • Parker1090
    Avatar
    Community Member
    38 Posts

    Uploaded File Management on a Page Link to this post

    Hello!

    I've got the front page of a site showing a slideshow, which uses images selected by the user through the CMS.

    The code added to the back end is as follows:

    class HomePage extends Page {
       static $many_many = array (
          'FrontImages' => 'Image'
       );
       
       static $allowed_children = '';
       
       public function getCMSFields() {
    $fields = parent::getCMSFields();

          $f = new UploadField('FrontImages', 'Front Images (Maximum of 10 images. Allowed files: .jpg, .jpeg, .png or .gif)', $this->FrontImages());
          $f   ->setConfig('allowedMaxFileNumber', 10)
             ->setFolderName('images/frontpage/')
             ->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
          $fields->addFieldToTab('Root.Images', $f);

    return $fields;
    }
       
    }

    This loads the boxes fine. However (as shown in the screenshot), there's no remove or delete buttons for the already uploaded images. Any help would be appreciated

    Thanks in advance!

    Attached Files
  • B00mtastikā„¢
    Avatar
    Community Member
    18 Posts

    Re: Uploaded File Management on a Page Link to this post

    Hello,

    Where are the images being uploaded to? Have you checked your asset folder under the "Files" menu item on the left hand side?

    It could be that Silverstripe sees that directory and you can control that directory from the File manager and you can delete, change, and add more files in/from there?

    If that doesn't work then you may have to code those features into this custom page?

    I'm still learning quite a lot, but what I've said above is just an idea to check out.

    -b00mer

    UPDATE/EDIT:
    It just clicked to me that the file manager would only pick it up if your images folder you created to keep those images, might only show up if they are inside the assets folder? If not then you definitely might have to code those features in (delete, edit etc), something I'd be interested in in the future as well.

  • Cleon
    Avatar
    Community Member
    1 Post

    Re: Uploaded File Management on a Page Link to this post

    Hi,

    I have the same issue, were you able to find a solution?

  • Parker1090
    Avatar
    Community Member
    38 Posts

    Re: Uploaded File Management on a Page Link to this post

    Hi,
    Sorry for the very long delay (shows how often I check back).

    I never found a solution, but would love to know one!

    The images are uploaded to Assets/Images (as defined in the code), but the images on the front page itself are pulled through using the following:

    <div id="slideshow">
       <ul id="carousel">
       <% loop $FrontImages %>
          <li>$croppedImage(930,300)</li>
       <% end_loop %>
       </ul>
    </div>

    The code in my first post has not changed.

    Cheers,
    Matt

  • Parker1090
    Avatar
    Community Member
    38 Posts

    Re: Uploaded File Management on a Page Link to this post

    I know this topic's a bit old, but I just thought I'd post a solution (finally).

    In my first post, I had the following code:

    $f = new UploadField('FrontImages', 'Front Images (Maximum of 10 images. Allowed files: .jpg, .jpeg, .png or .gif)', $this->FrontImages());

    However, the issue was the linking. Simply remove the red part as it seems to link everything up nicely anyway.

    $f = new UploadField('FrontImages', 'Front Images (Maximum of 10 images. Allowed files: .jpg, .jpeg, .png or .gif)', $this->FrontImages());

    I hope this helps someone in the future

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