5

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

So I just create the relation without mapping, so that I can later map it from setup.txt.

enter image description here

The I created model Pages in MyExt/Classes/Domain/Model/ with all the getters/setters and repository in MyExt/Classes/Domain/Repository/.

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
                            }
                }
            }
      }
    }
}

But when I try to access the Pages model I created,

var_dump($this->pagesRepository->findByUid(74));

its searching for tx_playfield_domain_model_pages which does not exists, it shows

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

What am I missing here?

Update

After following http://t3-developer.com/extbase-fluid/cheats-extbase/model/tabelle-pages-in-extbase/ suggested by @Michael I get an empty result from $this->pagesRepository->findByUid(74)

setup.txt is loading. I did this to check it:

plugin.tx_playfield{
settings{
 temp=yes
}
}

And this is being accessed from my controller.

4

2 回答 2

4

您是否有可能没有创建Pages域模型(在扩展构建器中或根本没有)?该文件my_ext/Classes/Domain/Model/Pages.php需要存在。检查您的“Pages”域模型是否将属性Map to existing table设置为pages,它应该如下所示:

在此处输入图像描述

我不知道你的错误到底出在哪里,但我在扩展生成器中做了一些修改并使它工作。您可以通过将您的扩展游戏场与我的临时扩展测试场进行比较来找出答案在此处下载(更新)


顺便说一句,您不需要映射不希望在前端显示的属性,除非它们的名称不同。

        mapping {
            tableName = pages
            columns {
                title.mapOnProperty = title
                subtitle.mapOnProperty = subtitle
            }
        }
于 2013-07-31T21:17:37.033 回答
1

我认为你必须用驼峰字母(类名)编写映射。虽然这篇文章是德语的,但我认为代码可能会对您有所帮助。作者在类中添加了一些他将要使用的字段,并在扩展的打字稿中添加了一个映射(参见那里的示例代码)。德语文本中最重要的部分是该示例仅设计为从 db 读取。如果您想使用模型创建新页面,您必须(至少)在模型类中添加 TCA 和设置器以使其工作。

于 2013-07-29T17:36:34.010 回答