extbase 映射到现有表不起作用
我已经扩展了页面表,现在我想使用名为“Tags”的域对象中的一些数据。
所以我在 /Configuration/TypoScript/setup.txt
中尝试了以下操作:
plugin.myextension.persistence.classes.Tx_myextension_Domain_Model_Tag {
mapping {
tableName = pages
recordType = Tx_myextension_Domain_Model_Tag
columns {
tx_myextension_tag_name.mapOnProperty = name
uid.mapOnProperty = id
}
}
}
但扩展程序似乎尝试访问表 Tx_myextension_Domain_Model_Tag (不存在)
这是我收到的错误:
Tx_Extbase_Persistence_Storage_Exception_SqlError `
表 'tx_myextension_domain_model_tag' 不存在: SELECT tx_myextension_domain_model_tag.* FROM tx_myextension_domain_model_tag WHERE tx_myextension_domain_model_tag.id = '24' LIMIT 1
我做错了什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
不要忘记将您的扩展打字稿模板包含到您的模板中(模板>编辑整个模板>包含静态模板),否则您的setup.txt不会被评估。
Don't forget to include your extension typoscript template into your template ( template > edit whole template > include static templates ), otherwise your setup.txt is not evaluated.
要检查哪些记录类型是可接受的,请使用 BE 中的配置模块,在 $TCA 部分中找到您的表(在本例中为 [pages])并检查类型列(...[ctrl][type] - 对于页面,它是“doktype” ',它决定页面记录是标准页面还是sysfolder等)。
该列在数据库中为tinyint(3),因此您不能向其中写入值“Tx_myextension_Domain_Model_Tag”。在 ext 中创建由数字标识的新 doktype 并将 recordType 设置为它。
如果页面的类型对您来说不重要,您可以选择从映射配置中删除 recordType 。
To check which recordType(s) are acceptable use Configuration module in BE, in $TCA section find your table ([pages] in this case) and check type column (...[ctrl][type] - for pages it's 'doktype', which decides if page record is standard page or sysfolder etc.).
This column is tinyint(3) in database, so you can not write value 'Tx_myextension_Domain_Model_Tag' to it. Create in your ext new doktype identified by number and set recordType to it.
Optionaly you can just remove recordType from mapping config if page's type doesn't matter to you.
您是否尝试过“config.tx_extbase”而不是“plugin.myextension”?
类似的东西
对我有用。
did you try "config.tx_extbase" instead of "plugin.myextension"?
Something like
works for me.
Tx_myextension_Domain_Model_Tag 是您的对象的名称,对吗?但我猜这不是您要访问的表的名称。所以我的猜测是您为值“tableName”提供的名称是错误的。 “页面”包含什么?
Tx_myextension_Domain_Model_Tag is the name of your object right ? But I guess this is not the name of the table you are trying to access. So my guess is that the name you are providing into the value "tableName" is wrong. What does "pages" contain ?
您是否将各个页面指定为记录类型
Tx_myextension_Domain_Model_Tag
?它应该进入页面表的 doctype 字段(因此您需要更改该字段的 mysql 数据类型。
否则 Extbase 不知道这个特定页面是 extbase 记录而不是常规页面。
查看有关 Extbase 中单表继承 (STI) 的更多信息:http://pascal-jungblut.com/blog/blog-post/2010/11/06/single-table-inheritance-in-extbase.html
Have you specified the individual pages as recordtype
Tx_myextension_Domain_Model_Tag
?It's supposed to go into the
doctype
field of the pages table (therefore you'll need to change the mysql datatype of that field.Otherwise Extbase doesn't know that this specific page is an extbase record and not a regular page.
See more about single table inheritance (STI) in Extbase: http://pascal-jungblut.com/blog/blog-post/2010/11/06/single-table-inheritance-in-extbase.html
你会在带有 eID 的typo3调用中执行此操作吗?
这里某些配置未加载..
如果是,请尝试加载所有配置是否可以解决问题:
do you do this in a typo3 call with eID?
here some configuration is not loaded ..
if yes, try if loading all configuration solves the problem:
请注意有关 FE 插件的正确命名约定:
Take care of the proper naming convention regarding FE-Plugins: