Hi,
I've been trying to make a simple Javascript slideshow and I want my user to choose the folder to get the pictures from.
Here is what I did: (removed unnecessary code)
In Page. php
public static $has_one = array(
'FolderForFadeBanner' => 'Folder'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Banner", new TreeDropdownField("FolderForFadeBannerID", "Choose a folder", "Folder"));
}
class Page_Controller extends ContentController {
function returnimages($dirname = "../assets/images/Homepage") {
(...)
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
(...)
In Page.ss
<script type="text/javascript">
(...)
imagearray: [ $returnimages],
(...)
</script>
This code works, because I obviously have declared a default value to be used with the returnimages() function.
My problem is that I want returnimages() to use the value collected from the CMS $FolderForFadeBanner.
I tried things like $returnimages($FolderForBanner) or <% control $returnimages($FolderForBanner) %> $files <% end_control %> in the ss file or declaring the function $returnimages($FolderForBanner) in the php file, but all to no avail.
At best, my slideshow works with the default folder.
At worst, I get an error, saying that I do not have enough arguments for returnimages.
Help please someone?
I know I am probably doing something really stupid, but I can't figure it out.
Thanks,
JuLo
[EDIT: Removed some more code that was not necessary. My post is still too long. Sorry. ]