How to have an extbase repository respect the l18n_cfg for models mapped onto the pages table?

198 Views Asked by At

If you map the pages table to an extbase model like so:

 return [
    \Lorem\Ipsum\Domain\Model\Newsarticle::class=>[
      'tableName'=>'pages',
      'properties'=>[
        // ...
      ],
    ],

and fetch the Newsarticles using the extbase repo (e.g. using findAll method), the repo will ignore the l18n_cfg settings.

So even if a page is set to "Hide in default language" it will be returned by the repo.

How to have the repo respect the l18n_cfg without filtering the records after fetching them?

1

There are 1 best solutions below

0
On BEST ANSWER

There is no way around this since not even TYPO3 itself integrates l18n_cfg into queries when fetching pages.

For this reason you need to call GeneralUtility::hideIfDefaultLanguage() yourself and decide if a page should be skipped.