Seite 1 von 4
Frage zu CMS_IMG
Verfasst: Fr 13. Feb 2015, 13:59
von derju
Hallo
Wenn ich folgendes in ein Modul packe und es ausgebe, erhalte ich keine Ausgabe.
Kann mir jemand sagen was hier nicht stimmt?
Danke
MFG derJu
Code: Alles auswählen
$art_idart = "18";
$art_lang = "1";
$obj = new cApiArticleLanguage();
$obj->loadByArticleAndLanguageId($art_idart, $art_lang);
$imageSource = $obj->getContent("CMS_IMG", 31);
echo $imageSource;
Re: Frage zu CMS_IMG
Verfasst: Fr 13. Feb 2015, 18:39
von derju
Wenn ich das selbe mit CMS_TEXT mache kommt die Ausgabe.
Wenn ich das mit CMS_LINK versuche kommt wie bei CMS_IMG keine Ausgabe.
LG - derJu
Re: Frage zu CMS_IMG
Verfasst: Sa 14. Feb 2015, 10:34
von Oldperl
Hallo derJu,
von welcher Ausgabe sprechen wir? Backend oder Frontend?
Gruß aus Franken
Ortwin
Re: Frage zu CMS_IMG
Verfasst: Sa 14. Feb 2015, 13:20
von derju
Hallo Ortwin,
Im Frontend.
Es soll ein Bild im Haupnavigationspunkt eingefügt werden und auf allen Unterpunkten angezeigt werden.
LG - derJu
Re: Frage zu CMS_IMG
Verfasst: Mo 16. Feb 2015, 11:31
von derju
Ich nochmal
Das funktioniert:
Code: Alles auswählen
<?php
// assert framework initialization
defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
// Fix Codierte Daten der Seite mit dem statischen Text
$art_idart = "CMS_VALUE[0]";
$art_client = 1;
$art_lang = 1;
// Erstelle Artikel Objekt
$obj = new cApiArticleLanguage();
$obj->loadByArticleAndLanguageId($art_idart, $art_lang);
// get text from content type HTML with index 1
$text = $obj->getContent("html", 2);
// When in backend edit mode add a label so the author
// knows what to type in the shown field.
if (cRegistry::isBackendEditMode()) {
$label = mi18n("LABEL_TEXT");
} else {
$label = NULL;
}
// use smarty template to output header text
$tpl = cSmartyFrontend::getInstance();
$tpl->assign('label', $label);
$tpl->assign('text', $text);
$tpl->display('get.tpl');
?>
Das funktioniert nicht:
Code: Alles auswählen
<?php
/**
* description: standard image
*
* @package Module
* @subpackage ContentImage
* @version SVN Revision $Rev:$
*
* @author marcus.gnass@4fb.de
* @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
*/
// assert framework initialization
defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
$art_idart = "CMS_VALUE[0]";
$art_client = 1;
$art_lang = 1;
// get image source from content type IMG with index 1
// Erstelle Artikel Objekt
$obj = new cApiArticleLanguage();
$obj->loadByArticleAndLanguageId($art_idart, $art_lang);
// get text from content type HTML with index 1
$imageSource = $obj->getContent("CMS_IMG", 31);
echo $imageSource;
// get description as content type IMGDESCR with index 1
$imageDescription = $obj->getContent("imgdescr", 31);
$slider_str_url = getEffectiveSetting('image', 'url', 1);
// build class containing all data necessary to display image
// therefor the image dimensions have to be determined
if (0 < strlen($imageSource)) {
$clientConfig = cRegistry::getClientConfig(cRegistry::getClientId());
$filename = str_replace($clientConfig["upl"]["htmlpath"], $clientConfig["upl"]["path"], $imageSource);
$aa = cApiImgScale($filename, 800, 800, false, false, 100);
$img = str_replace($slider_str_url, '', $aa);
list($imageWidth, $imageHeight) = getimagesize($filename);
$image = new stdClass();
$image->src = cApiImgScale($img, 740, 400, true, 95);
$image->alt = $imageDescription;
$image->width = $imageWidth;
$image->height = $imageHeight;
} else {
$image = NULL;
}
// When in backend edit mode add a label so the author
// knows what to type in the shown field.
if (cRegistry::isBackendEditMode()) {
$label = mi18n("LABEL_IMAGE");
} else {
$label = NULL;
}
// use smarty template to output header text
$tpl = cSmartyFrontend::getInstance();
$tpl->assign('label', $label);
//$tpl->assign('editor', $imageEditor);
$tpl->assign('image', $image);
$tpl->display('get.tpl');
?>
Was mach ich falsch?
LG - derJu
Re: Frage zu CMS_IMG
Verfasst: Do 19. Feb 2015, 11:36
von derju
Ich habe noch keine Lösung gefunden.
Hat jemand noch eine Idee?
LG - derJu
Re: Frage zu CMS_IMG
Verfasst: Do 19. Feb 2015, 12:21
von homtata
hallo,
laut beschreibung der von dir verwendeten klasse
http://api.contenido.org/con490/class-c ... guage.html
stimmt vermutlich der aufruf in getcontent für diesen typ nicht. dort steht:
htmlhead - HTML Headline
html - HTML Text
headline - Headline (no HTML)
text - Text (no HTML)
img - Upload id of the element
imgdescr - Image description
link - Link (URL)
linktarget - Linktarget (_self, _blank, _top ...)
linkdescr - Linkdescription
swf - Upload id of the element
Re: Frage zu CMS_IMG
Verfasst: So 22. Feb 2015, 19:51
von derju
hallo,
ich habe das auch schon mit $imageSource = $obj->getContent("img", 31); versucht ohne erfolg.
LG - derJu
Re: Frage zu CMS_IMG
Verfasst: So 22. Feb 2015, 21:49
von homtata
woher kommt eigentlicht die "31"?
Kannst du den Parameter mal weglassen und schauen, was dann im Array landet?
Also:
Re: Frage zu CMS_IMG
Verfasst: Mo 23. Feb 2015, 07:33
von Oldperl
homtata hat geschrieben:woher kommt eigentlicht die "31"?
Doch wohl aus seinem Modul-Output, der den Content-Type Image mit der Nummer 31 nutzt. Ohne Angabe der Nummer liefert die Klassenmethode alle vorhandenen Inhalte des Content-Types als Array zurück.
derju hat geschrieben:Was mach ich falsch?
Du hast zumindest den Image-Editor vergessen, ohne diesen kannst du den Content-Type nicht setzen und es wird auch kein entsprechender Button im Backend angezeigt.
Gruß aus Franken
Ortwin
Re: Frage zu CMS_IMG
Verfasst: Mo 23. Feb 2015, 08:11
von derju
Hallo Ortwin
das ist mir schon klar, hatte ich vergessen:
$imageSource = $obj->getContent("img", 31);
Den Image-Editor benötige ich nicht, da ich das Bild aus einem anderen Artikel vererben will.
Wie schon gesagt mit der Überschrift und dem Text funktioniert das ohne Probleme nur mit dem Bild funktioniert das bei mir nicht.
LG - derJu
Re: Frage zu CMS_IMG
Verfasst: Mo 23. Feb 2015, 08:58
von derju
Kannst du den Parameter mal weglassen und schauen, was dann im Array landet?
Es wird nicht's ausgegeben.
LG - derJu
Re: Frage zu CMS_IMG
Verfasst: Mo 23. Feb 2015, 09:04
von homtata
blöde Frage:
Ist das Bild im Originalartikel, das du auslesen willst, überhaupt mit CMS_IMG eingebunden oder über irgendeinen anderen Weg? Dann wird das nämlich nicht klappen... teste doch mal, ob überhaupt was ausgelesen wird, indem du in der if-Schleife unterschiedlich Dummy-Werte ausgibst. Es ist denke ich immer noch unklar, ob der contenttype überhaupt vorhanden/ausgelesen wird oder ob das schon gar nicht passiert...
Re: Frage zu CMS_IMG
Verfasst: Mo 23. Feb 2015, 09:48
von derju
Ja das Bild wurde über CMS_IMG eingebunden. Wenn ich ein echom mit test ausgebe funktioniert das.
Das Problem liegt hier eigentlich sollte die id ausgegeben werden:
Code: Alles auswählen
$obj = new cApiArticleLanguage();
$obj->loadByArticleAndLanguageId($art_idart, $art_lang);
// get text from content type HTML with index 1
$img = $obj->getContent("img", 31);
echo $img;
Wenn ich so den Text ausgebe geht das ohne Probleme:
Code: Alles auswählen
$obj = new cApiArticleLanguage();
$obj->loadByArticleAndLanguageId($art_idart, $art_lang);
// get text from content type HTML with index 1
$text = $obj->getContent("html", 1);
echo $text;
LG - derJu
Re: Frage zu CMS_IMG
Verfasst: Mo 23. Feb 2015, 11:32
von homtata
hast du denn jetzt mal meinen vorschlag getestet, das ganze OHNE die 31 einzulesen und dann mal zu schauen, was im Array landet? Da die 31 nicht zwingend ist, denke ich immer noch, dass da irgendwo der Fehler liegt und er auf diese konkrete Abfrage halt keinen Treffer kriegt.