TYPO3:将internal_type=file_reference迁移到FAL

发布于 2025-01-12 08:12:45 字数 1277 浏览 0 评论 0原文

我有一个旧的 TYPO3 网站,它使用带有以下代码的图像选择器:

    'tx_my_image' => array(
        'label' => 'Image',
        'exclude' => 1,
        'config' => array(
            'type' => 'group',
            'internal_type' => 'file_reference',
            'allowed' => 'gif,jpg,jpeg,png',
            'show_thumbs' => 1,
            'size' => 1,
            'maxitems' => 1,
            'minitems' => 0,
        )
    ),

这在 TYPO3 中不再起作用:

10(错误:“表格页面中字段 tx_my_image 的 TCA 内部类型 必须设置为“db”或“folder”。”)

所以,我将其更改为如下所示:

    'tx_my_image' => array(
        'label' => 'Image',
        'exclude' => 1,
        'config' => ExtensionManagementUtility::getFileFieldTCAConfig('tx_my_image', [
            'show_thumbs' => 1,
            'size' => 1,
            'maxitems' => 1,
            'minitems' => 0
        ], 'gif,jpg,jpeg,png'),
    ),

这有效,因为后端不再抛出致命错误,但我现在的问题是不再找到所有先前选择的图像之前,图像的路径存储在页面表中的字段tx_my_image中(这样做可能不是一个好主意,但当我开始维护站点时已经是这样了)。

这个网站有很多页面,所以手动重做所有图像选择是不可行的,所以我的问题是,有没有办法将我的旧数据转换为新 TYPO3 版本期望的任何格式,或者更好的是配置表单以查找当前形式的数据?

I have an older TYPO3 site that uses image pickers with the following code:

    'tx_my_image' => array(
        'label' => 'Image',
        'exclude' => 1,
        'config' => array(
            'type' => 'group',
            'internal_type' => 'file_reference',
            'allowed' => 'gif,jpg,jpeg,png',
            'show_thumbs' => 1,
            'size' => 1,
            'maxitems' => 1,
            'minitems' => 0,
        )
    ),

This does not work anymore in TYPO3:

10 (Error: "TCA internal type of field tx_my_image in table pages
must be set to "db" or "folder".")

So, I changed it to look like this:

    'tx_my_image' => array(
        'label' => 'Image',
        'exclude' => 1,
        'config' => ExtensionManagementUtility::getFileFieldTCAConfig('tx_my_image', [
            'show_thumbs' => 1,
            'size' => 1,
            'maxitems' => 1,
            'minitems' => 0
        ], 'gif,jpg,jpeg,png'),
    ),

This works because the backend no longer throws fatal errors, but my problem now is that all the previously selected images are no longer found. Before, the path of the images was stored in a field tx_my_image in the pages table (it's probably not a good idea to do that, but it was like this already when I started maintaining the site).

This site has many pages, so manually redoing all the image selections is unfeasible. So my question is, is there a way to either convert my old data to whatever format the new TYPO3 version expects or, better yet, to configure the form to find the data in its current form?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷路的信 2025-01-19 08:12:45

“新的typo3版本需要什么格式”是一个文件抽象层关系,在8年前的“新版本”TYPO3 6.2中引入(2014年3月25日发布);)

所以,FAL的基础知识例如升级到 FAL 可以在文档中阅读。


有多种解决方案,但其中大多数需要针对您的自定义扩展进行调整/配置:

1.扩展“connetation:// FAL Migration”

此扩展(适用于 TYPO3 6.2)可以帮助迁移到 FAL。
https://extensions.typo3.org/extension/conn_falmigration

2.查看 EXT:news

Georg 已将以前的迁移代码(用于 hist EXT:news)提取到一个额外的扩展中。查看代码可以显示必须完成哪些步骤。
https://packagist.org/packages/georgringer/news-fal-migration

<强>3。大部分是手动的

只需一点 PHP 脚本就可以处理:

输入数据是记录的 uid 和文件的路径。该路径必须采用现在用作新表 sys_file 中的 identifier 列的形式。

<?php
// each line: recordUid;pathOfFile
$csv = "1;/user_upload/test.pdf
2;/user_upload/image.jpg";

$lines = str_getcsv($csv, chr(10));
$pid = 123;

foreach ($lines as $line) {
    $row = str_getcsv($line, ';');
    $row = array_map('trim', $row);
    $uid = $row[0];
    $filePath = $row[1];
    if ($filePath && $filePath !== '""') {
        $uid = trim($uid);
        echo "INSERT INTO sys_file_reference (pid, uid_local, uid_foreign, tablenames, fieldname, table_local) VALUES($pid, (SELECT uid FROM sys_file WHERE identifier=\"" . $filePath . "\"), $uid, 'yourTable ', 'tx_my_image', 'sys_file');" . chr(10);
    }
}

这将生成用于插入所需 FAL 关系的 SQL 查询。

The "whatever format the new typo3 version expects" is a File Abstraction Layer relation, introduced in the "new version" TYPO3 6.2 8 years ago (released on 25.03.2014) ;)

So, the basics of FAL e.g. Upgrading to FAL can be read in the docs.


There are several solutions, but most of them need to be adapted/configured for your custom extension:

1. Extension "connetation:// FAL Migration"

This extension (for TYPO3 6.2) could help to migrate to FAL.
https://extensions.typo3.org/extension/conn_falmigration

2. Have a look into EXT:news

Georg has extracted the former migration code (for hist EXT:news) to an extra extension. Looking into the code could show, which steps have to be done.
https://packagist.org/packages/georgringer/news-fal-migration

3. Mostly be manual

With a little PHP script it can be handled:

Input data is the uid of the record and the path to your file. That path has to be in a form that is now used as identifier-columns in the new table sys_file.

<?php
// each line: recordUid;pathOfFile
$csv = "1;/user_upload/test.pdf
2;/user_upload/image.jpg";

$lines = str_getcsv($csv, chr(10));
$pid = 123;

foreach ($lines as $line) {
    $row = str_getcsv($line, ';');
    $row = array_map('trim', $row);
    $uid = $row[0];
    $filePath = $row[1];
    if ($filePath && $filePath !== '""') {
        $uid = trim($uid);
        echo "INSERT INTO sys_file_reference (pid, uid_local, uid_foreign, tablenames, fieldname, table_local) VALUES($pid, (SELECT uid FROM sys_file WHERE identifier=\"" . $filePath . "\"), $uid, 'yourTable ', 'tx_my_image', 'sys_file');" . chr(10);
    }
}

This will generate SQL-Queries for inserting the needed FAL relations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文