简体   繁体   English

如何在 TYPO3 的数据库中创建记录并添加图像

[英]How to create a record and add an image in database in TYPO3

I use TYPO3 version 10.4.21 and I created an own extension for leaflet.我使用 TYPO3 版本 10.4.21 并为 leaflet 创建了自己的扩展。

In frontend I can't see a picture.在前端我看不到图片。

My code in js-file for now:我现在在 js 文件中的代码:

var map = L.map('map', {crs: L.CRS.Simple});
var bounds = [[0,0], [750,1200]];
L.imageOverlay("../Parks/Park.png", bounds).addTo(map);
map.fitBounds(bounds);

The path for the picture is right, but I can't display the picture "Park.png".图片的路径是正确的,但我无法显示图片“Park.png”。
Then I thought there is no data in my database.然后我以为我的数据库中没有数据。

In ext.tables.sql:在 ext.tables.sql 中:

CREATE TABLE tx_interaktivekarte_domain_model_park (
    image int(11) DEFAULT NULL,
    bgcolor varchar(255) DEFAULT NULL,
    markers int(11) DEFAULT NULL,
    icon varchar(255) DEFAULT NULL,
    iccolor int(11) DEFAULT NULL,
    pin int(11) DEFAULT NULL,
    title varchar(255) DEFAULT NULL,
    marker int(11) unsigned NOT NULL DEFAULT '0'
);

CREATE TABLE tx_interaktivekarte_domain_model_marker (
    park int(11) unsigned DEFAULT '0' NOT NULL,
    title varchar(255) DEFAULT NULL,
    lat varchar(255) DEFAULT NULL,
    lon varchar(255) DEFAULT NULL,
    contenthtml text DEFAULT NULL,
    icon varchar(255) DEFAULT NULL,
    text text DEFAULT NULL
);

How can I add a image in a database?如何在数据库中添加图像?

I referred an extension: https://docs.typo3.org/p/onm/int-park/1.0/en-us/Installation/Index.html And there is written "Under any folder, create a db record 'Park', add image in it.".我提到了一个扩展名: https://docs.typo3.org/p/onm/int-park/1.0/en-us/Installation/Index.ZFC35FDC70D5FC69D2698883A822C7A5文件夹,E 创建一个 Zdb 记录,其中写有“Parkder”任何文件夹,E ,在其中添加图像。”。 Maybe I have to do it same thing in my extension, but I don't know what the text means.也许我必须在我的扩展程序中做同样的事情,但我不知道文本的含义。

What do I have to do to display my picture on leaflet?我该怎么做才能在 leaflet 上显示我的图片? And is it because of database?是因为数据库吗?

I have aright to access into database with phpMyAdmin.我有权使用 phpMyAdmin 访问数据库。

Thank you for your help.谢谢您的帮助。

In TYPO3 you should store images as references.在 TYPO3 中,您应该将图像存储为参考。 TYPO3 provides a File Abstraction Layer which you and your extension should use. TYPO3 提供了您和您的扩展程序应该使用的文件抽象层。

That starts with integration in TCA, see: https://docs.typo3.org/m/typo3/reference-tca/10.4/en-us/ColumnsConfig/Type/Inline.html#file-abstraction-layer从 TCA 的集成开始,请参阅: https://docs.typo3.org/m/typo3/reference-tca/10.4/en-us/ColumnsConfig/Type/Inline.html#file-abstraction-layer

For the frontend output, you can refer to this part of the documentation: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Fal/UsingFal/Frontend.html For the frontend output, you can refer to this part of the documentation: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Fal/UsingFal/Frontend.html

So, two short points:所以,有两个要点:

  1. Correct integration in backend via TCA and references通过 TCA 和参考在后端正确集成
  2. Correct integration in frontend via Image ViewHelper and either fetching FileReference object via Extbase or via DataProcessing.通过 Image ViewHelper 在前端正确集成,并通过 Extbase 或通过 DataProcessing 获取 FileReference object。

In TYPO3 files are handled normally by FAL (File Abstraction Layer).在 TYPO3 中,文件由 FAL(文件抽象层)正常处理。 This means: you get a record with relevant information of the file.这意味着:您将获得包含文件相关信息的记录。 in any record which references a file you have symbolic DB-field (with just a counter in it) and you have MM-records which connects the sys_file records of the file to your record.在任何引用文件的记录中,您都有符号 DB 字段(其中只有一个计数器),并且您有 MM 记录,它将文件的sys_file记录连接到您的记录。

Your example probably includes special records where files can be referenced.您的示例可能包括可以引用文件的特殊记录。

If you develop extensions you can use this manual to get more information about structure of files and records.如果您开发扩展,您可以使用本手册来获取有关文件和记录结构的更多信息。

You also can have a look into the declaration of other records like the extension you gave as example.您还可以查看其他记录的声明,例如您提供的扩展名。
The currently best example would always be the declaration of the core.目前最好的例子总是核心的声明。
For an example how to include files in a record I would suggest the table tt_content and the field media .对于如何在记录中包含文件的示例,我建议使用表tt_content和字段media
The important part is the TCA declaration, as this configures the 'magic' how an integer field from the database table is connected to a file.重要的部分是 TCA 声明,因为它配置了数据库表中的 integer 字段如何连接到文件的“魔术”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM