Hallo homtata,
ich bin noch ein Neuling in Contenido, habe aber einen Lösungsvorschlag für dich. Ich hatte nämlich das selbe Problem. Ich brauchte den Titel der Bilder. Im alten
Contenido gab es dafür CMS_IMGTITLE, im 4.9 gibt es diesen anscheinend nicht mehr.
Es gibt aber CMS_IMGDESC.
Ich habe CMS_IMGTITLE selbst erstellt (ausgehend von CMS_IMGDESC).
Folgende Schritte sind dafür nötig:
In der Datenbank die Tabelle "
con_type" (kann anders heißen) um den Eintrag
CMS_IMGTITLE erweitern. Bitte für "idtype" eine ID größer als 10000 nehmen, denn wie ich irgendwo gelesen habe, werden beim upgrate alle Einträge <10000 gelöscht.
Nun muss die angepasste Version von CMS_IMGDESC mit dem Namen "
include.CMS_IMGTITLE.code.php" ins richtige Verzeichniss kopiert werden.
"
/contenido/includes/type/code".
Jetzt sollte mit "CMS_IMGTITLE[1]" im Modul der Titel abrufbar sein.
Um weitere Metatags abzurufen, muss im Source der Klassenname entsprechend geändert werden und bei "generateViewCode()", der entsprechende Wert zurückgegeben werden. Und natürlich "con_type" erweitert werden.
Erklärung:
Die neue Klasse "cContentTypeImgtitle" geht von "cContentTypeImgeditor" aus. "cContentTypeImgeditor" weiß alle Metatags, aber diese sind als private deklariert und stehen uns hier somit nicht zur Verfügung. Deswegen werden bei "generateViewCode()" die MetaTags erneut eingelesen.
Ich hoffe ich konnte dir helfen.
Lg
Hier der angepaste Code für "include.CMS_IMGTITLE.code.php"
Code: Alles auswählen
<?php
/**
* This file contains the cContentTypeImgdescr class.
*
* @package Core
* @subpackage ContentType
* @version SVN Revision $Rev:$
*
* @author Simon Sprankel
* @copyright four for business AG <www.4fb.de>
* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
*/
defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
/**
* Content type CMS_IMGDESCR which displays the description of the selected
* image.
*
* @package Core
* @subpackage ContentType
*/
class cContentTypeImgtitle extends cContentTypeImgeditor {
/**
* Initialises class attributes and handles store events.
*
* @param string $rawSettings the raw settings in an XML structure or as
* plaintext
* @param integer $id ID of the content type, e.g. 3 if CMS_DATE[3] is
* used
* @param array $contentTypes array containing the values of all content
* types
* @return void
*/
public function __construct($rawSettings, $id, array $contentTypes) {
// there are no raw settings here, because the image description is now
// saved in con_upl_meta
// so compute the appropriate raw settings and call the parent
// constructor with them
// if the content type value is not passed, get it from the DB
if (!isset($contentTypes['CMS_IMGEDITOR'][$id])) {
$idArtLang = cRegistry::getArticleLanguageId();
// get the idtype of the CMS_IMGEDITOR content type
$typeItem = new cApiType();
$typeItem->loadByType('CMS_IMGEDITOR');
$idtype = $typeItem->get('idtype');
// first load the appropriate content entry in order to get the
// idupl
$content = new cApiContent();
$content->loadByMany(array(
'idartlang' => $idArtLang,
'idtype' => $idtype,
'typeid' => $id
));
$rawSettings = $content->get('value');
} else {
$rawSettings = $contentTypes['CMS_IMGEDITOR'][$id];
}
parent::__construct($rawSettings, $id, $contentTypes);
}
/**
* Generates the code which should be shown if this content type is shown in
* the frontend.
*
* @return string escaped HTML code which sould be shown if content type is
* shown in frontend
*/
public function generateViewCode() {
// get image information from con_upl_meta from the database
$uploadMeta = new cApiUploadMeta();
$uploadMeta->loadByMany(array(
'idupl' => $this->_rawSettings,
'idlang' => $this->_lang
));
$medianame = ($uploadMeta->get('medianame') !== false) ? $uploadMeta->get('medianame') : '';
// $this->_description = ($uploadMeta->get('description') !== false) ? $uploadMeta->get('description') : '';
// $this->_keywords = ($uploadMeta->get('keywords') !== false) ? $uploadMeta->get('keywords') : '';
// $this->_internalNotice = ($uploadMeta->get('internal_notice') !== false) ? $uploadMeta->get('internal_notice') : '';
// $this->_copyright = ($uploadMeta->get('copyright') !== false) ? $uploadMeta->get('copyright') : '';
return $this->_encodeForOutput($medianame) ;
}
/**
* Generates the code which should be shown if this content type is edited.
*
* @return string escaped HTML code which should be shown if content type is
* edited
*/
public function generateEditCode() {
return $this->generateViewCode();
}
}