Danke für die schnelle Antwort.
Ok, ich bin ziemlich am Anfang mit Typolight und habe jetzt die Sache mit den Hooks in der Anleitung gelesen. Die generelle Funktionalität hat sich mir erschlossen, aber zum laufen habe ich das nicht bekommen.
Ich habe mir die Liste der zur Verfügung stehenden Hooks angesehen und gedacht, dass ich entweder mit 'outputFrontendTemplate' oder 'parseFrontendTemplate' was werden sollte. Ich habe die Vorgaben entsprechend angepasst.
'config.php' im Verzeichnis 'config' meiner Erweiterung:
PHP-Code:
<?php $GLOBALS['TL_HOOKS']['parseFrontendTemplate'][] = array('ContentTeaser', 'parseFrontendTemplate');
?>
'ContentTeaser.php' im root meiner Erweiterung:
PHP-Code:
<?php
public function parseFrontendTemplate($strContent, $strTemplate)
{
if ($strTemplate == 'ContentTeaser')
{
class ContentTeaser extends ContentElement
{
/**
* Template
* @var string
*/
protected $strTemplate = 'ce_teaser';
/**
* Generate content element
*/
protected function compile()
{
$objArticle = $this->Database->prepare("SELECT p.id AS id, p.alias AS alias, a.id AS aid, a.title AS title, a.alias AS aalias, a.teaser AS teaser, a.teaser_image AS teaser_image, a.teaser_image_alt AS teaser_image_alt, a.inColumn AS inColumn FROM tl_article a, tl_page p WHERE a.id=? AND a.pid=p.id")
->limit(1)
->execute($this->article);
if ($objArticle->numRows < 1)
{
return;
}
$link = '/articles/';
if ($objArticle->inColumn != 'main')
{
$link .= $objArticle->inColumn . ':';
}
$link .= (strlen($objArticle->aalias) && !$GLOBALS['TL_CONFIG']['disableAlias']) ? $objArticle->aalias : $objArticle->aid;
$this->Template->href = $this->generateFrontendUrl($objArticle->row(), $link);
$this->Template->headline = $objArticle->title;
$this->Template->text = $objArticle->teaser;
$this->Template->image = $objArticle->teaser_image;
$this->Template->image_alt = $objArticle->teaser_image_alt;
$this->Template->more = $GLOBALS['TL_LANG']['MSC']['more'];
}
}
}
return $strContent;
}
?>
Das Resultat ist ein weißer Bildschirm. Irgendwelche Ideen?
Lesezeichen