Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping to "pages" table from Extbase in TYPO3 6.1

Tags:

typo3

extbase

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.

like image 972
dora Avatar asked Jul 29 '13 15:07

dora


1 Answers

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:

enter image description here

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
            }
        }
like image 174
Mateng Avatar answered Sep 21 '22 07:09

Mateng