Hello, I'm very new to SilverStripe and like the title says, I'm trying to upload multiple images at once and then be able to display them through my template. I haven't been able to get it to work how I want it to. I'm using SilverStripe 3.
The code for my ImagePage.php file is below where I create the form in the CMS, everything uploads to the "Images" folder I created within the assets folder just fine.
<?php
class ImagePage extends Page {
static $has_many = array(
"PageImages" => "Image"
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', $uploadField = new UploadField('PageImages'));
$fields->removeFieldFromTab('Root.Main', 'Content');
$uploadField->setFolderName('Images');
return $fields;
}
}
class ImagePage_Controller extends Page_Controller {
}
?>
The code for my template is as follows:
<% if PageImages %>
<% loop PageImages %>
<img src="$URL" alt="$Title" />
<% end_loop %>
<% end_if %>
The problem is that when I go to view the page that should be displaying the images, they don't display and instead have the "non existant/broken link" image in its place. When I inspect the element it shows that the url being supplied by $URL is '/silverstripe/assets/image1.jpg instead of what I want, '/silverstripe/assets/images/image1.jpg'.
I can't seem to find anything that simply explains how to display multiple images from within a specific folder. I would greatly appreciate it if someone could explain the steps necessary to making this work for me.