Tag typo3

Repository for existing Extbase model class

If you want to use an existing extbase model like Category but want to create a custom repository to implement some custom queries, here is the way to go:

Create typo3conf/ext/your_ext/Classes/Domain/Model/Category.php:

<?php
namespace Dummy\YourExt\Domain\Model;
/**
 * Category
 */
class Category extends \TYPO3\CMS\Extbase\Domain\Model\Category {

}

Create typo3conf/ext/your_ext/Classes/Domain/Repository/CategoryRepository.php:

<?php
namespace Dummy\YourExt\Domain\Repository;
/**
 * The repository for Categories
 */
class CategoryRepository extends \TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository {
    // some custom query methods here
}

Create typo3conf/ext/your_ext/ext_typoscript_setup.txt:

config.tx_extbase{
    persistence{
        classes{
            Dummy\YourExt\Domain\Model\Category {
                mapping {
                    tableName = sys_category
                    recordType = Tx_YourExt_Category
                }
            }
        }
    }
}

Clear the cache and you're ready to go!

FE-Plugin with multilingual TYPO3

I always forget how to force a frontend plugin to display the texts localized through $this->pi_getLL($key).

This is how it works:

class tx_extkey_piX extends tslib_pibase {
   function main() {
      $this->sys_language_uid = (int) t3lib_div::_GP('L');
      ...
   }
}