Hi.
I'm very new on SS (working on first page) and I stumbled upon very weird situation.
For news page, client wanted the gallery, so I downloaded one frankmullenger/gallery. Now that one has small thing I wanted to change without any "change" to actual module due to update possibilities: upload folder and try to make it also dynamical.
Idea is simple - use setFolderName("news/subfolder") - where subfolder is changing based on URLSegment of the specific article/page.
So I came up with solution that I created the new class inside the page code:
class GalleryModule_PageExtension extends Gallery_PageExtension{
public function updateCMSFields(FieldList $fields){
$fields -> removeFieldFromTab("Root.Gallery", "Images");
$fields->addFieldToTab('Root.Gallery', $newsImage = GalleryUploadField::create(
'Images',
'',
$this->owner->OrderedImages()
));
$newsImage -> setFolderName("News-Images/".<WANT_URLSegment_HERE>);
}
}
what then extends the part where files input is created so, that it will remove the default, creates new and adds the folder name (that seamed like most reasonable way to do it). So far so good (no problems there), added into yaml file of extension the necessary info for that specific class.
Now problem starts, when trying to get the URLSegment part for that specific article/news (Gallery is as a tab for that news). What ever I try, I either get an error of that method not allowed or browsers 500 error page.
Any ideas or suggestion how to resolve that issue?
Thank you.