【问题标题】:How to access local paths on TYPO3 using eID如何使用 eID 访问 TYPO3 上的本地路径
【发布时间】:2012-11-12 17:45:49
【问题描述】:

我的前端有一个图像映射,我需要从那里访问一些存储在 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。我想这可能是解决这个问题的更聪明的方法。

有什么建议吗?

【问题讨论】:

    标签: ajax typo3 fluid extbase


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2011-12-11
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多