[TYPO3-mvc] Language overlay for table pages

Kevin Ulrich Moschallski km at 3digit.de
Tue Nov 23 17:41:28 CET 2010


Hi list,

i currently have one special problem:

I have a list of pages where i display the title in my extension as a link list. Everything is working fine so far. But when i add a translation to the page i run into a problem:

The link is generated fine, the uriBuilder works fine but the title of the page is in the default language ($page->getTitle()). This is of course because the pages table has a different localization method with it's own table pages_language_overlay for that.

I now tried to translate the page objects while getting the translation from a new pageLanaguageOverlay with a custom query. This works fine. But my problem is that i have an object with the pages as children. I don't know how to "replace" the original page children with the translated ones before passing it to the view.

Here is what i got to far:

The translate function:
/**
	 *
	 * @param Tx_Favourites_Domain_Model_Page $page
	 */
	public function getPageLanguageOverlay(Tx_Favourites_Domain_Model_Page $page) {
		$pageLanguageOverlayRepository = t3lib_div::makeInstance('Tx_Favourites_Domain_Repository_PageLanguageOverlayRepository');
		return $pageLanguageOverlayRepository->findOneByPageAndLanguageId($page);
	}

The approach to replace:

/**
		 * TODO Add pages_language_overlay for translated page titles
		 */
		// page language overlay
		foreach($favourites as $favourite) {
			foreach($favourite->getFavpages() as $favpage) {
				$pageLanguageOverlay = $this->getPageLanguageOverlay($favpage);
				if(!empty($pageLanguageOverlay)) {
					//$favourite->removeFavpage($favpage);
					//$favourite->addFavpage($pageLanguageOverlay);
				}
			}
		}

I'm not sure if my approach with an extra function to translate the objects is very good, maybe it would be better to do this within the repository.

I hope somebody has an idea on that.

Regards,

Kevin


More information about the TYPO3-project-typo3v4mvc mailing list