[TYPO3-dev] property Mappe, tt_adress

Jigal van Hemert jigal.van.hemert at typo3.org
Sat Mar 28 11:33:33 CET 2015


Hi,

On 28/03/2015 09:58, Christian Tauscher wrote:
> english/german group did not solve the problem, so I giv it a try here:
>
> I want to use the tt_address table in my EXT. Easy? NO!
>
> TYPO3 6.2, all Caches are cleared, confg.no_cache ist set and a 'rm -R
> typo3temp/Cache/*' is done. Even the cache-tables are cleared via
> phpmyadmin.
>
> I get the output in my view exept...
>
> e.g. country is missing.
> If I add
>
> /**
>   * country
>   * @var country
>   */
> protected $country = '';
>
> the EXT fails with:
> #1264093630: Found an invalid element type declaration in %s. A type
> "'country'" does not exist.

After @var you should define the PHP type. If 'country' is simply a text 
field (TCA: input) then it should be @var string
If it links to another object you put the fully qualified class name of 
the model there: @var \Tmd\Screenprinting\Domain\Model\Country

This way extbase knows that it should convert the identifier into a 
Country object.

> If I change the TSsetup, e.g. clearing all the mapping part I expect the
> EXT to fail what does not happen. Why?
> e.g. plugin.tx_screenprinting.persistence.mapping >

Extbase tries to do some default mapping (just like when you create an 
extension with its own database table such as 
tx_screenprinting_domain_model_address). See below.

> If I change e.g.
> columns.gender.mapOnProperty = gender
> to
> columns.gender.mapOnProperty = first_name
> I expect  the first_name as ouput for gender.
> Nope. Still see the original gender filed.
[... together with ...]
 >        mapping {
 >          tableName = tt_address
 >          recordType = Tmd\Screenprinting\Domain\Model\Address
 >
 >          columns {
 >            gender.mapOnProperty = gender
 >            firstName.mapOnProperty = first_name
 >            middleName.mapOnProperty = middle_name

I think you mean it the other way around:
<db_column_name>.mapOnProperty = <propertyNameInModel>

If the only difference is that on the left the name has underscores, 
while on the right the underscores are removed and the letter after the 
underscore is upppercase then you can leave the mapping out:

   first_name.mapOnProperty = firstName   # can be left out
   last_name.mapOnProperty = familyName   # is necessary

> Next strange thing:
> <f:debug>{addresses}</f:debug>
> I get the fluid result, all the addresses.
> the addresses contain all the fields. Should...
> Missing: birthday.
> Is this because the field can be negative (UX Timestamp before epoche)?

First get the mapping complete and get all the types in your model correct.
The birthday field is probably an integer with the timestamp. If I'm not 
mistaken that should be handled as an integer and in your fluid template 
you can use viewhelper to display it as a date. I'm not sure if you set 
it as @var \DateTime in your model and have extbase do the converting 
for you.

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org



More information about the TYPO3-dev mailing list