[TYPO3-mvc] Syntax Property eines Objekt im Controller
Sebastian Schreiber
me at schreibersebastian.de
Thu Nov 15 16:14:30 CET 2012
You have to override the page title with:
$GLOBALS['TSFE']->page['title'] = $title
But be aware of the fact that non cached plugin (USER_INT) are not able
to override the title the way described.
If you have a non-cached plugin you have to override the page title the
following way:
$GLOBALS['TSFE']->content = preg_replace('#<title>.*<\/title>#',
'<title>' . $title . '</title>', $GLOBALS['TSFE']->content);
And actually it would be better to use a viewhelper for that.
class Tx_MyExt_ViewHelpers_Meta_PageTitleViewHelper extends
Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
/**
* renders a special title for the page
*
* @param string $title
* @return string $content: The pagebrowser
*/
public function render($title = NULL) {
if (NULL === $title) {
$title = $this->renderChildren();
}
$title = trim($title);
if ($this->controllerContext->getRequest()->isCached()) {
$GLOBALS['TSFE']->page['title'] = $title;
$GLOBALS['TSFE']->indexedDocTitle = $title;
} else {
$GLOBALS['TSFE']->content =
preg_replace('#<title>.*<\/title>#', '<title>' . $title . '</title>',
$GLOBALS['TSFE']->content);
}
}
}
Am 15.11.2012 15:47, schrieb Kerstin Finke:
> Dear List,
>
> I have a detailview in my controller. The action gets the object as
> parameter and the detailview is shown correctly in the frontend.
>
> What I want now:
>
> I want to show the title of the object as pagetitle (instead of
> "SingleViewPage" or something like that)
>
> What is the correct syntax? I tried this:
>
>
> /**
> * Show action for this controller ( SingleView)
> * @param Tx_HnmImmo_Domain_Model_Flat $flat The flat to be shown
> * @return string
> */
> public function showAction(Tx_HnmImmo_Domain_Model_Flat $flat) {
>
> $title = $flat->title;
> $GLOBALS['TSFE']->indexedDocTitle = $title;
>
> $this->view->assign('flats', $flat);
> }
>
>
> I tried also:
> $title = $flat->Tx_HnmImmo_Domain_Model_Flat['title'];
>
> Can someone please help? Thanks in advance!
> Kerstin
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
--
Sebastian Schreiber
(Medieninformatiker B.Sc.)
(TYPO3 Certified Integrator)
Schanzenstraße 27, Schlosserei 4
D-51063 Köln
T 0221 677 88 541
M 0176 431 05 790
Skype schreibersebastian.de
me at schreibersebastian.de
www.schreibersebastian.de
Steuernummer: 217 / 5269 / 4675
More information about the TYPO3-project-typo3v4mvc
mailing list