AgenturPottkinder / typo3_forum

An Extbase-based TYPO3 Extension which is called typo3_forum
http://www.mittwald.de
GNU General Public License v2.0
35 stars 54 forks source link

Trying to extend the userfields #158

Closed Joe1am closed 7 years ago

Joe1am commented 7 years ago

Hello!

I'm trying to extend the userfield list on the profile page with some extra fe_users attributes.

In setup.txt there are already a view fields set up like this:

            username {
                class = Mittwald\Typo3Forum\Domain\Model\User\Userfield\TextUserfield
                properties {
                    name = LLL:EXT:typo3_forum/Resources/Private/Language/locallang_user.xml:Username
                    mapToUserObject = username
                }
            }

            registered_since {
                class = Mittwald\Typo3Forum\Domain\Model\User\Userfield\DateUserfield
                properties {
                    name = LLL:EXT:typo3_forum/Resources/Private/Language/locallang_user.xml:RegisteredSince
                    mapToUserObject = crdate
                }
            }

            real_name {
                class = Mittwald\Typo3Forum\Domain\Model\User\Userfield\TextUserfield
                properties {
                    name = LLL:EXT:typo3_forum/Resources/Private/Language/locallang_user.xml:RealName
                    mapToUserObject = name
                }
            }

and i can add a normal fe_user attribute like this

            first_name {
                class = Mittwald\Typo3Forum\Domain\Model\User\Userfield\TextUserfield
                properties {
                    name = Vorname
                    mapToUserObject = firstName
                }
            }

so far, it's easy :)

But I created another little extension which extends my fe_users with some custom fields..

The ext_typoscript_setup.txt looks like this

config.tx_extbase{
    persistence{
        classes{
            TYPO3\CMS\Extbase\Domain\Model\FrontendUser {
                subclasses {
                    Tx_FeUsersExtraFields_ExtraFields = Feusersextrafields\FeUsersExtraFields\Domain\Model\ExtraFields
                }
            }
            Feusersextrafields\FeUsersExtraFields\Domain\Model\ExtraFields {
                mapping {
                    tableName = fe_users
                    recordType = Tx_FeUsersExtraFields_ExtraFields
                }
            }
        }
    }
}

and my class in Classes/Domain/Model is

<?php
namespace Feusersextrafields\FeUsersExtraFields\Domain\Model;

/**
 * ExtraFields
 */
class ExtraFields extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
{
... 
}

So, how can I get the custom fields on the profile page? When trying to add a field

            ef_weight {
                class = Feusersextrafields\FeUsersExtraFields\Domain\Model\ExtraFields
                properties {
                    name = Gewicht
                    mapToUserObject = efWeight
                }
            }

I get an error which says that Feusersextrafields\FeUsersExtraFields\Domain\Model\ExtraFields is not a subclass of \Mittwald\Typo3Forum\Domain\Model\User\Userfield\AbstractUserfield

I also tried to extend the AbstractUserfield class like so..

config.tx_extbase.persistence.classes{
  Mittwald\Typo3Forum\Domain\Model\User\Userfield\AbstractUserfield {
    subclasses {
      Tx_FeUsersExtraFields_ExtraFields = TYPO3\CMS\Extbase\Domain\Model\FrontendUser
        }
  }
}

but unfortunately without any success :(

Can anyone help me with that?

pstranghoener commented 7 years ago

Did you use the Plugin Userfield in Listview Mode to extended the Fields?

Joe1am commented 7 years ago

As I said, I extended the fields with my custom extension "Feusersextrafields" I found the solution: The mapping in my ext_typoscript_setup.txt was wrong

This is the working ext_typoscript_setup.txt


config.tx_extbase{
  persistence{
    classes{
      Mittwald\Typo3Forum\Domain\Model\User\FrontendUser {
        subclasses {
          Tx_FeUsersExtraFields_ExtraFields = Feusersextrafields\FeUsersExtraFields\Domain\Model\ExtraFields
        }
      }
      Feusersextrafields\FeUsersExtraFields\Domain\Model\ExtraFields {
        mapping {
          tableName = fe_users
          recordType = Mittwald\Typo3Forum\Domain\Model\User\FrontendUser
        }
      }
    }
  }
}