Hallo,
anbei ein kleines Beispiel wie man opengraph Metadaten dynamisch auf CustomCatalog-Leser Seiten platzieren kann. (Dank an Lars)
Modul: CustomCatalog Leser, Template-Basis: customcatalog_default
Viele Grüße,
Tim
anbei ein kleines Beispiel wie man opengraph Metadaten dynamisch auf CustomCatalog-Leser Seiten platzieren kann. (Dank an Lars)
Modul: CustomCatalog Leser, Template-Basis: customcatalog_default
Code:
// opengraph
$objFileModel = \FilesModel::findByPk( $this->field('MEIN-BILD')->value() );
$objFile = new \File($objFileModel->path, true);
$arrOG = array
(
'og:url' => \Environment::get('base').\Environment::get('request'),
'og:type' => "Website",
'og:title' => $this->field('MEIN-TITEL')->value(),
'og:description' => $this->field('MEINE-BESCHREIBUNG')->value(),
'og:image' => \Environment::get('base').$objFileModel->path,
'og:image:width' => $objFile->__get('width'),
'og:image:height' => $objFile->__get('height'),
);
foreach($arrOG as $prop => $content)
{
$GLOBALS['TL_HEAD'][] = '<meta property="'.$prop.'" content="'.$content.'">';
}
Tim
