[TYPO3-mvc] FAL Translation failed in View

Gianluca Strafella gianluca.strafella at webformat.com
Fri Sep 27 09:20:59 CEST 2013


Hi Benjamin,
the problem in the action "show"  could be caused by method 
"findByIdentifier" in the core class 
TYPO3\CMS\Extbase\Persistence\Repository.
The action "Show", implicitly calls findByUid, but if you see core 
method "findByUid", you will see that it invokes method "findByIdentifier".
On top of method body, there is this comments:

> /**
> 		 * @todo: This method must be changed again in 6.2 + 1
> 		 * This is marked @deprecated to be found in cleanup sessions.
> 		 *
> 		 * The repository should directly talk to the backend which
> 		 * does not respect query settings of the repository as
> 		 * findByIdentifier is strictly defined by finding an
> 		 * undeleted object by its identifier regardless if it
> 		 * is hidden/visible or a versioning/translation overlay.
> 		 *
> 		 * As a consequence users will be forced to overwrite this method
> 		 * and mimic this behaviour to be able to find objects by identifier
> 		 * respecting their query settings from 6.1 + 1 on.


I think that you would overwrite method in your Repository class to make 
sure that the action "show" works fine with translations ...

Regards,
Gianluca

Gianluca Strafella

Software Developer
gianluca.strafella at webformat.com
Tel.   +39-0427-926.389

WEBFORMAT srl – www.webformat.com
Via S. Francesco d'Assisi, 6 – 20122 MILANO
Corte Europa, 12 - 33097 SPILIMBERGO (PN)


Il 18/09/2013 15:52, Benjamin Giesbrecht ha scritto:
> Hy Together,
>
> General: I'm using FAL to show an image Gallery in the Frontend. I have
> a "collection" Object with two actions, List and Show. A collection
> contains n file references and a titel. That works beautiful, except the
> translation handling. In the backend i can create a new data record in
> default language. After i create a new data record in an other language,
> as well i link it to the data record with the default language. Both
> contains some images with metafield like "title", "alt"... Those are all
> translatet.
> Now the Problem: My List View works great, the title is translatet as
> well. But my Show view doesn't work in other languages. It shows all the
> pictures of the default language. Also the meta fields comes in default
> language. I tried to fix it over a day, now i'm at the end of my mind.
>
> Somebody know this problem?
>
> Settings:
>
> MODEL
> -----------
> class Collection extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
>
>      /**
>       * Title of the collection
>       *
>       * @var \string
>       * @validate NotEmpty
>       */
>      protected $title;
>
>      /**
>       * a collection have got n images
>       *
>       * @var
> \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
>
>       */
>      protected $images;
>
>      /**
>       * __construct
>       *
>       * @return Collection
>       */
>      public function __construct() {
>          //Do not remove the next line: It would break the functionality
>          $this->initStorageObjects();
>      }
>
>      /**
>       * Initializes all ObjectStorage properties.
>       *
>       * @return void
>       */
>      protected function initStorageObjects() {
>          /**
>           * Do not modify this method!
>           * It will be rewritten on each save in the extension builder
>           * You may modify the constructor of this class instead
>           */
>          $this->images = new
> \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
>      }
>
>      /**
>       * Returns the title
>       *
>       * @return \string $title
>       */
>      public function getTitle() {
>          return $this->title;
>      }
>
>      /**
>       * Sets the title
>       *
>       * @param \string $title
>       * @return void
>       */
>      public function setTitle($title) {
>          $this->title = $title;
>      }
>
>      /**
>       * Returns the images
>       *
>       * @return
> \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
> $images
>       */
>      public function getImages() {
>          return $this->images;
>      }
>
>      /**
>       * Sets the images
>       *
>       * @param
> \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
> $images
>          * @return void
>       */
>      public function setImages($images) {
>          $this->images = $images;
>      }
> }
>
>
> CONTROLLER
> ---------------------
>
> class CollectionController extends
> \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
>
>      /**
>       * collectionRepository
>       *
>       * @var \BFA\ShGallery\Domain\Repository\CollectionRepository
>       * @inject
>       */
>      protected $collectionRepository;
>
>      /**
>       * action list
>       *
>       * @return void
>       */
>      public function listAction() {
>          $collections = $this->collectionRepository->findAll();
>          $this->view->assign('collections', $collections);
>      }
>
>      /**
>       * action show
>       *
>       * @param \BFA\ShGallery\Domain\Model\Collection $collection
>       * @return void
>       */
>      public function showAction(\BFA\ShGallery\Domain\Model\Collection
> $collection) {
>          $this->view->assign('collection', $collection);
>      }
>
> }
>
> TCA
> -------
>
> 'title' => array(
>              'exclude' => 0,
>              'label' =>
> 'LLL:EXT:sh_gallery/Resources/Private/Language/locallang_db.xlf:tx_shgallery_domain_model_collection.title',
>
>              'config' => array(
>                  'type' => 'input',
>                  'size' => 30,
>                  'eval' => 'trim,required'
>              ),
>          ),
>          'images' => array(
>             'exclude' => 0,
>             'label' =>
> 'LLL:EXT:sh_gallery/Resources/Private/Language/locallang_db.xlf:tx_shgallery_domain_model_collection.images',
>
>             'config' => array(
>                 'maxitems' => 999,
>                 'type' => 'inline',
>                 'foreign_table' => 'sys_file_reference',
>                 'foreign_field' => 'uid_foreign',
>                 'foreign_sortby' => 'sorting_foreign',
>                 'foreign_table_field' => 'tablenames',
>                 'foreign_match_fields' => array(
>                     'fieldname' => 'images'
>                 ),
>                 'foreign_label' => 'uid_local',
>                 'foreign_selector' => 'uid_local',
>                 'foreign_selector_fieldTcaOverride' => array(
>                     'config' => array(
>                         'appearance' => array(
>                             'elementBrowserType' => 'file',
>                             'elementBrowserAllowed' =>
> $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
>                         )
>                     )
>                 ),
>                 'appearance' => array(
>                     'createNewRelationLinkTitle' =>
> 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference',
>                     'useSortable' => TRUE,
>                     'collapseAll' => 1,
>                     'expandSingle' => 1,
>                     'headerThumbnail' => array(
>                         'field' => 'uid_local',
>                         'width' => '64',
>                         'height' => '64',
>                     ),
>                     'showPossibleLocalizationRecords' => TRUE,
>                     'showRemovedLocalizationRecords' => TRUE,
>                     'showSynchronizationLink' => TRUE,
>                     'enabledControls' => array(
>                         'info' => FALSE,
>                         'new' => FALSE,
>                         'dragdrop' => TRUE,
>                         'sort' => FALSE,
>                         'hide' => TRUE,
>                         'delete' => TRUE,
>                         'localize' => TRUE,
>                     ),
>                 ),
>                 'behaviour' => array(
>                     'localizationMode' => 'select',
>                     'localizeChildrenAtParentLocalization' => TRUE,
>                 ),
>             ),
>         ),
>
>


More information about the TYPO3-project-typo3v4mvc mailing list