问题描述
我使用域模型Message
创建了扩展.该模型与TYPO3 pages
表(具有页面详细信息,例如标题,issite_root等)的关系为m:n.但是,通过使用mapping to existing tables
选项,它会向我显示type
错误,提示页面:
I created an extension with a domain model Message
. This model has a relation m:n with the TYPO3 pages
(the one which has the details of the pages, like title, issite_root etc) table. However, by using the mapping to existing tables
option, it gives me type
error saying page :
The configured type field for table "pages" is of type int(11) unsigned
This means the type field can not be used for defining the record type.
You have to configure the mappings yourself if you want to map to this
table or extend the correlated class
因此,我只创建了没有映射的关系,以便以后可以从setup.txt
映射它.
So I just create the relation without mapping, so that I can later map it from setup.txt
.
我在MyExt/Classes/Domain/Model/
中创建了模型Pages
,并在MyExt/Classes/Domain/Repository/
中创建了所有获取器/设置器和存储库.
The I created model Pages
in MyExt/Classes/Domain/Model/
with all the getters/setters and repository in MyExt/Classes/Domain/Repository/
.
在我的setup.txt文件中,我这样做了:
In my setup.txt I did this:
config.tx_extbase {
persistence{
enableAutomaticCacheClearing = 1
updateReferenceIndex = 0
classes {
Tx_Playfield_Domain_Model_Pages {
mapping {
tableName = pages
columns {
uid.mapOnProperty = uid
pid.mapOnProperty = pid
sorting.mapOnProperty = sorting
title.mapOnProperty = title
subtitle.mapOnProperty = subtitle
}
}
}
}
}
}
但是当我尝试访问我创建的Pages模型时,
But when I try to access the Pages model I created,
var_dump($this->pagesRepository->findByUid(74));
搜索不存在的tx_playfield_domain_model_pages
,它显示
Table 'typo3.tx_playfield_domain_model_pages' doesn't exist: SELECT tx_playfield_domain_model_pages.* FROM tx_playfield_domain_model_pages WHERE tx_playfield_domain_model_pages.uid = '74' LIMIT 1
我在这里想念什么?
更新
关注 http://之后@Michael建议的t3-developer.com/extbase-fluid/cheats-extbase/model/tabelle-pages-in-extbase/我从$this->pagesRepository->findByUid(74)
setup.txt
正在加载.我这样做是为了检查它:
setup.txt
is loading. I did this to check it:
plugin.tx_playfield{
settings{
temp=yes
}
}
这是从我的控制器访问的.
And this is being accessed from my controller.
推荐答案
是否有可能没有创建 Pages 域模型(在扩展生成器内部还是根本没有)?文件my_ext/Classes/Domain/Model/Pages.php
必须存在.检查您的页面"域模型是否将属性"映射到现有表"设置为"页面",它应该看起来像这样:
Is it possible that you didn't create the Pages domain model (within the extension builder or not at all)? The file my_ext/Classes/Domain/Model/Pages.php
needs to exist. Check that your "Pages" domain model has the property Map to existing table set to pages, it should look like that:
我不知道您的错误到底在哪里,但是我在扩展构建器中做了一些修改,并使它起作用.您可以通过将扩展名 playfield 与我的临时扩展名 testfield 进行比较来找出:在此处下载(更新).
I don't know where exactly your error is, but I did some more tinkering in the extension builder and made it work. You can probably find out by comparing your extension playfield to my temporary extension testfield: Download it here (updated).
顺便说一句,除非您用不同的名称命名,否则您不需要映射不想显示在前端的属性.
Btw, you don't need to map properties that you do not want to be displayed in the frontend unless they are named differently.
mapping {
tableName = pages
columns {
title.mapOnProperty = title
subtitle.mapOnProperty = subtitle
}
}
这篇关于映射到“页面" TYPO3 6.1中来自Extbase的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!