0

我的前端有一个图像映射,从那里我需要访问一些存储在 fileadmin 目录下不同文件夹中的图像。我正在尝试使用 eID 来做这件事,按照这个例子:[http://www.alexanderschnitzler.de/2011/06/howto-ajax-requests-with-extbase-and-fluid/][1]

但我的问题是我只能访问一个目录。我无法根据前端的用户选择访问不同的目录。

这是我一直在尝试做的代码: 在我的控制器上,我有一个 ajaxAction,我需要在其中提供一个目录的完整路径,因为我还没有弄清楚如何将目录 ID 传递给我的 ajaxAction,这可能是我的问题,也许是解决方案:

/**
 * @return void
 */
public function ajaxAction() {

    $image_file_path = "fileadmin/Images/Sattic/Amik/small";
    //$image_file_path = "fileadmin/Images/Sattic/'+$id+'";
    $d = dir($image_file_path) or die("Wrong path: $image_file_path");
    while (false !== ($entry = $d ->read())) {
        if($entry != '.' && $entry != '..' && !is_dir($dir.$entry)) 
        $images[] = $entry;
    }
    $d->close();

    rsort($images);
    return json_encode($images);
}

在我的 index.html 上,我有一个 map 标记,当用户单击不同的区域时调用函数 updateImage(id) 并且我的 updataImage(id) 函数如下所示:

function updateImageGallery(id) {
console.log(id);

var ajaxUrl = "{f:uri.action(action:'ajax', pageType:'100101')}";

$.getJSON(ajaxUrl, function(data) {
    var items1 = [];
    var items2 = [];
    $data = data;
    console.log('dataLength: ' + $data.length);
    console.log('dataArray: ' + $data);

    $.each($data.slice(0, 4), function(key, val) {
        valLink = val.replace("small.", "");
        items1.push('<td><a href="fileadmin/Images/Sattic/' + id +'/'+ valLink +'" target="_blank"><img width="145" height="145" id="" src="fileadmin/Images/Sattic/' + id +'/small/'+ val +'"/></a></td>');
    });
    $('<tr/>', {
        html: items1.join('')
    }).appendTo('#glRegion');

    $.each($data.slice(4, 8), function(key, val) {
        valLink = val.replace("small.", "");
        items2.push('<td><a href="fileadmin/Images/Sattic/' + id +'/'+ valLink +'" target="_blank"><img width="145" height="145" id="" src="fileadmin/Images/Sattic/' + id +'/small/'+ val +'"/></a></td>');
    });
    $('<tr/>', {
        html: items2.join('')
    }).appendTo('#glRegion');

});
return false;

}

我希望能够从 updateImageGallery(id) 函数传递目录的 id,这样我就可以获得每个目录的图像。

是否有可能做到这一点?我希望如此,我有 30 个不同的区域,如果我以现在的方式解决我的问题,我将需要使用 30 个不同的 eID。我想这可能是解决这个问题的更聪明的方法。

有什么建议吗?

4

1 回答 1

0

您可以使用t3lib_div::_GET('myid')来访问myidget 变量。

我想你可以用var ajaxUrl = "{f:uri.action(action:'ajax',**myid:id,** pageType:'100101')}";它来设置它。

无论如何,请确保在 PHP 脚本中生成有效路径/ID 列表,并再次检查 get 参数。

于 2012-11-13T19:11:04.563 回答