Variable gesucht

Gesperrt
anubis2k
Beiträge: 50
Registriert: Fr 27. Jul 2007, 13:39
Kontaktdaten:

Variable gesucht

Beitrag von anubis2k » Mi 7. Mai 2008, 20:27

Juhu.. ich habe da mal eine kleine Frage..
Ich verwende ein 4.6.23 und baue mir eine kleine Newsliste,
aber da hätte ich ganz gerne noch Angaben drin wie
- Veröffentlicht am (Datum reicht "07.05.2008")
- Veröffentlicht von

Könnt Ihr mir da irgend wie weiter helfen?
Bitte keine Fragen wieso ich 4.6.x benutze ;)

Danke schon mal für die Hilfe.

Halchteranerin
Beiträge: 5478
Registriert: Di 2. Mär 2004, 21:11
Wohnort: Halchter, wo sonst? ;-)
Kontaktdaten:

Beitrag von Halchteranerin » Mi 7. Mai 2008, 20:46

such bei den Modulen, entweder 4.4.x oder 4.6.x, "letzte Änderung".
Bitte keine unaufgeforderten Privatnachrichten mit Hilfegesuchen schicken. WENN ich helfen kann, dann mache ich das im Forum, da ich auch alle Postings lese. PN werden nicht beantwortet!

anubis2k
Beiträge: 50
Registriert: Fr 27. Jul 2007, 13:39
Kontaktdaten:

Beitrag von anubis2k » Mi 7. Mai 2008, 22:28

Ah.. ich hab da was gefunden hier im Forum :D
-> http://forum.contenido.org/viewtopic.php?t=15141

Aber irgend wie verstehe ich das Prinzip noch nicht so ganz..
Kann ich nicht einfach in dem News Modul folgendes einbinden,

Code: Alles auswählen

$tpl->set("s","PUBLISHED",    $oArticle->getField('published') );
$tpl->set("s","PUBLISHED_BY", $oArticle->getField('publishedby') );
Und hinterher baue ich dann in dem teaser-standard.html einfach folgendes einbinden...

Code: Alles auswählen

<div class="news-bottom">Geschrieben von:{PUBLISHED_BY}, am: {PUBLISHED}</div>
Oder stelle ich mir das ganze gerade zu einfach vor? :D

Oldperl
Beiträge: 4250
Registriert: Do 30. Jun 2005, 22:56
Wohnort: Eltmann, Unterfranken, Bayern
Kontaktdaten:

Beitrag von Oldperl » Do 8. Mai 2008, 08:10

Hallo anubis2k,

die von dir angesprochenen Codestücke bauen wohl auf die Klasse Artikel auf. Nähere Infos dazu findest du unter
:arrow: http://faq.contenido.org/index.php?acti ... artlang=de

Gruß aus Franken

Ortwin
ConLite 2.1, alternatives und stabiles Update von Contenido 4.8.x unter PHP 7.x - Download und Repo auf Gitport.de
phpBO Search Advanced - das Suchwort-Plugin für CONTENIDO 4.9
Mein Entwickler-Blog

delinquent
Beiträge: 184
Registriert: Fr 17. Aug 2007, 12:15
Kontaktdaten:

Beitrag von delinquent » Do 8. Mai 2008, 11:30

anubis2k hat geschrieben:Und hinterher baue ich dann in dem teaser-standard.html einfach folgendes einbinden...
Oder stelle ich mir das ganze gerade zu einfach vor? :D
Nein, ist schon richtig. Ergänze einfach folgendes, dann klappts (ungetestet):

Code: Alles auswählen

cInclude("classes", "class.article.php");
$oArticle = new Article(null, null, null, $idartlang);

$tpl->set("s","PUBLISHED",    $oArticle->getField('published') );
$tpl->set("s","PUBLISHED_BY", $oArticle->getField('publishedby') );
Wenn Du allerdings auf weitere Daten des Nutzers zugreifen willst, musst Du weitere Klassen zu Rate ziehen (auch ohne Gewähr):

Code: Alles auswählen

cInclude("classes", "class.article.php");
cInclude("classes", "class.user.php");
$oArticle = new Article(null, null, null, $idartlang);

$oUser = new User;
$oUser->loadUserByUsername($oArticle->getField('publishedby'));

$pub = date('d.m.Y, H:i', strtotime($oArticle->getField('published'))) . " " . mi18n("Uhr");

$tpl->set("s","PUBLISHED", htmlspecialchars($pub));
$tpl->set("s","PUBLISHED_BY", htmlspecialchars($oUser->getField('realname')));

Gruß,
Manuel

anubis2k
Beiträge: 50
Registriert: Fr 27. Jul 2007, 13:39
Kontaktdaten:

Beitrag von anubis2k » Do 8. Mai 2008, 13:32

Juhu.. ich habe meine Blöcke nun wie folgt angepasst..

Code: Alles auswählen

cInclude('classes', 'class.article.php');
$oArticle = new Article(null, null, null, $idartlang);

cInclude('includes', 'functions.api.string.php');
cInclude('includes', 'functions.api.images.php');
Da habe ich ja nur noch deinen Part oben eingefügt im Original und
unten im unteren Part der Ausgabe habe ich dann folgendes eingebunden..

Code: Alles auswählen

			$tpl->set('d', 'HEADLINE', $teaserheadline);
			$tpl->set('d', 'TEXT', $teasertext);
			$tpl->set('d', 'HREF', $href);
			$tpl->set('d', 'IMG', $teaser_img);
			$tpl->set('d', 'MORE', mi18n("mehr"));

			$tpl->set('d', 'PUBLISHED',    $oArticle->getField('published') );
			$tpl->set('d', 'PUBLISHED_BY', $oArticle->getField('publishedby') );


			$tpl->next();
Jetzt gibt es mir die Infos raus die ich schon mal gerne hätte :)
Kann ich das Datum anpassen, so das er mir nur das Datum ausgibt und nicht die Uhrzeit?
Genau so beim publisher, da zeigt er mir den Login Namen an (z.B. sysadmin),
kann ich das auch verändern, so das er mir den Namen angibt?!

Aber schon mal besten Dank für die Informationen :)

anubis2k
Beiträge: 50
Registriert: Fr 27. Jul 2007, 13:39
Kontaktdaten:

Beitrag von anubis2k » Do 8. Mai 2008, 20:53

Muh.. geht doch nicht so wie ich das möchte..
Er verwendet für jeden Eintrag den ich gemacht habe die gleichen Daten :(

Überall steht die gleiche Uhrzeit und der gleiche Ersteller :(

Vom Prinzip her klappen beide deiner Lösungen mit einer kleinen
Abänderung, dass finde ich schon mal sehr sehr cool :)

Aber hast du noch einen Tipp für mich, ich packe jetzt mal stumpf meinen
Ausgabecode mit hinzu zu diesem Post und hoffe das hilft bei der Suche
von dem Fehler den ich machte :)

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname  :      News
* Author(s)   :     Andreas Lindner, 4fb
* Copyright   :     Contenido - four for business, Andreas Lindner
* Created     :     12.08.2005
************************************************/

cInclude("classes", "class.article.php");
cInclude("classes", "class.user.php");
$oArticle = new Article(null, null, null, $idartlang);

$oUser = new User;
$oUser->loadUserByUsername($oArticle->getField('publishedby'));

$pub = date('d.m.Y', strtotime($oArticle->getField('published'))) . " " . mi18n("");

cInclude('includes', 'functions.api.string.php');
cInclude('includes', 'functions.api.images.php');

if (!is_object($tpl)) {
	$tpl = new Template;
}

$tpl->reset();

$sql = "SELECT
            htmlpath, frontendpath
        FROM
            ".$cfg["tab"]["clients"]." 
        WHERE
            idclient = ".$client." ";

$db->query($sql);

if ($db->next_record()) {
	$htmlpath = $db->f('htmlpath');
	$frontendpath = $db->f('frontendpath');
}

// selected category
$selcat = "CMS_VALUE[1]";
$template = "teaser-standard.html";
// anzahl der zeichen text
$mxtext = 300;

$limit = "CMS_VALUE[15]";

$cms_sort_direction = "CMS_VALUE[16]";
if ($cms_sort_direction == '') {
	$cms_sort_direction = 'desc';
}

if ("CMS_VALUE[3]" == "sortdate") {
	$order = 'lastmodified';
} else {
	$order = 'artsort';
}

if ("CMS_VALUE[17]" != '') {
	$with_start = true;
} else {
	$with_start = false;
}

$newsheadline = "CMS_VALUE[4]";

$tpl->set('s', 'TITLE', $newsheadline);

if (strlen($selcat) > 0 && $selcat != '0') {
	$options = array ('idcat' => $selcat, "start" => $with_start, "order" => $order, "direction" => $cms_sort_direction);

	$list = new ArticleCollection($options);

	$count = $list->count;

	if ($count > 0) {
		if (is_numeric($limit) AND strlen($limit) > 0) {
			if ($limit < $list->count) {
				$limit_art = $limit;
			} else {
				$limit_art = $list->count;
			}
		} else {
			$limit_art = $list->count;
		}

		for ($i = 0; $i < $limit_art; $i ++) {

			$article = $list->nextArticle();

			$article_id = $article->getField('idart');

			$teaser_img = '';
			if ($noimg != 'true') {
				$text_html = $article->getContent('CMS_HTML', 1);

				$regEx = "/<img[^>]*?>.*?/i";
				$match = array ();
				preg_match($regEx, $text_html, $match);

				$regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
				$img = array ();
				preg_match($regEx, $match[0], $img);
				$img_src = preg_split("/\//", $img[0]);

				$img_name = $img_src[count($img_src) - 1];
				$img_name = preg_replace("/\"/", "", $img_name);
				$img_split = preg_split("/\./", $img_name);
				$img_type = $img_split[count($img_split) - 1];

				$img_split2 = preg_split("/_/", $img_split[0]);

				$name = $img_name;

				if (count($img_split2) > 1) {
					$img_x = $img_split2[count($img_split2) - 1];
					$img_y = $img_split2[count($img_split2) - 2];

					if (is_numeric($img_x) AND is_numeric($img_y)) {
						$suffix = "_".$img_x."_".$img_y.".".$img_type;
						$name = preg_replace("/$suffix/", "", $img_name);
						$name = $name.".[a-zA-Z]{3}";
					}
				}

				$img_teaser = '';

				if (strlen($name) > 0) {
					$sql = "SELECT
													*
												FROM
													".$cfg["tab"]["upl"]." 
												WHERE
													filename REGEXP '$name' ";

					//echo "<pre>"; print_r($sql); echo "</pre>";

					$db->query($sql);

					if ($db->next_record()) {
						$filename = $db->f('filename');
						$dirname = $db->f('dirname');
					}

					$img_path = $cfgClient[$client]["upl"]["path"].$dirname.$filename;

					$img_size = "CMS_VALUE[14]";

					$img_teaser = capiImgScale($img_path, $img_size, $img_size, $crop = false, $expand = false, $cacheTime = 1000, $wantHQ = false);
				} // end if strlen

				if (strlen($img_teaser) > 0) {
					$teaser_img = '<img src="'.$img_teaser.'" class="teaser_img">';
				} else {
					$teaser_img = '';
				}

			} // end if noimg 		

			$headline = strip_tags($article->getContent('CMS_HTMLHEAD', 1));
			$headline = str_replace($replace, " ", $headline);

			/*			$subheadline = strip_tags($article->getContent('CMS_HTMLHEAD', 2));
						$subheadline = str_replace($replace, " ", $subheadline);*/

			$teaserheadline = /*$subheadline."&nbsp;-&nbsp;".*/
			$headline;
			$href = $sess->url("front_content.php?idcat=$selcat&idart=$article_id");
			$teasertext = $article->getField('summary');

			if (strlen(trim($teasertext)) == 0) {
				$teasertext = strip_tags($article->getContent('CMS_HTML', 1));
				$teasertext2 = $teasertext;
				$teasertext = capiStrTrimAfterWord($teasertext, $mxtext);
				if ($teasertext!=$teasertext2) {
					$teasertext.= '...';
				}
				
			} // end if   			

			$teasertext = $teasertext."&nbsp;";

			$tpl->set('d', 'HEADLINE', $teaserheadline);
			$tpl->set('d', 'TEXT', $teasertext);
			$tpl->set('d', 'HREF', $href);
			$tpl->set('d', 'IMG', $teaser_img);
			$tpl->set('d', 'MORE', mi18n("mehr"));

			$tpl->set('d', 'PUBLISHED',    htmlspecialchars($pub) );
			$tpl->set('d', 'PUBLISHED_BY', htmlspecialchars($oUser->getField('realname')) );


			$tpl->next();

		} // end for

		$tpl->generate('templates/'.$template);

	}
}
?>

delinquent
Beiträge: 184
Registriert: Fr 17. Aug 2007, 12:15
Kontaktdaten:

Beitrag von delinquent » Fr 9. Mai 2008, 08:54

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname  :      News
* Author(s)   :     Andreas Lindner, 4fb
* Copyright   :     Contenido - four for business, Andreas Lindner
* Created     :     12.08.2005
************************************************/

cInclude("classes", "class.article.php");
cInclude("classes", "class.user.php");

cInclude('includes', 'functions.api.string.php');
cInclude('includes', 'functions.api.images.php');

if (!is_object($tpl)) {
	$tpl = new Template;
}

$tpl->reset();

$sql = "SELECT
            htmlpath, frontendpath
        FROM
            ".$cfg["tab"]["clients"]." 
        WHERE
            idclient = ".$client." ";

$db->query($sql);

if ($db->next_record()) {
	$htmlpath = $db->f('htmlpath');
	$frontendpath = $db->f('frontendpath');
}

// selected category
$selcat = "CMS_VALUE[1]";
$template = "teaser-standard.html";
// anzahl der zeichen text
$mxtext = 300;

$limit = "CMS_VALUE[15]";

$cms_sort_direction = "CMS_VALUE[16]";
if ($cms_sort_direction == '') {
	$cms_sort_direction = 'desc';
}

if ("CMS_VALUE[3]" == "sortdate") {
	$order = 'lastmodified';
} else {
	$order = 'artsort';
}

if ("CMS_VALUE[17]" != '') {
	$with_start = true;
} else {
	$with_start = false;
}

$newsheadline = "CMS_VALUE[4]";

$tpl->set('s', 'TITLE', $newsheadline);

if (strlen($selcat) > 0 && $selcat != '0') {
	$options = array ('idcat' => $selcat, "start" => $with_start, "order" => $order, "direction" => $cms_sort_direction);

	$list = new ArticleCollection($options);

	$count = $list->count;

	if ($count > 0) {
		if (is_numeric($limit) AND strlen($limit) > 0) {
			if ($limit < $list->count) {
				$limit_art = $limit;
			} else {
				$limit_art = $list->count;
			}
		} else {
			$limit_art = $list->count;
		}

		for ($i = 0; $i < $limit_art; $i ++) {

			$article = $list->nextArticle();

			$article_id = $article->getField('idart');

			$teaser_img = '';
			if ($noimg != 'true') {
				$text_html = $article->getContent('CMS_HTML', 1);

				$regEx = "/<img[^>]*?>.*?/i";
				$match = array ();
				preg_match($regEx, $text_html, $match);

				$regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
				$img = array ();
				preg_match($regEx, $match[0], $img);
				$img_src = preg_split("/\//", $img[0]);

				$img_name = $img_src[count($img_src) - 1];
				$img_name = preg_replace("/\"/", "", $img_name);
				$img_split = preg_split("/\./", $img_name);
				$img_type = $img_split[count($img_split) - 1];

				$img_split2 = preg_split("/_/", $img_split[0]);

				$name = $img_name;

				if (count($img_split2) > 1) {
					$img_x = $img_split2[count($img_split2) - 1];
					$img_y = $img_split2[count($img_split2) - 2];

					if (is_numeric($img_x) AND is_numeric($img_y)) {
						$suffix = "_".$img_x."_".$img_y.".".$img_type;
						$name = preg_replace("/$suffix/", "", $img_name);
						$name = $name.".[a-zA-Z]{3}";
					}
				}

				$img_teaser = '';

				if (strlen($name) > 0) {
					$sql = "SELECT
													*
												FROM
													".$cfg["tab"]["upl"]." 
												WHERE
													filename REGEXP '$name' ";

					//echo "<pre>"; print_r($sql); echo "</pre>";

					$db->query($sql);

					if ($db->next_record()) {
						$filename = $db->f('filename');
						$dirname = $db->f('dirname');
					}

					$img_path = $cfgClient[$client]["upl"]["path"].$dirname.$filename;

					$img_size = "CMS_VALUE[14]";

					$img_teaser = capiImgScale($img_path, $img_size, $img_size, $crop = false, $expand = false, $cacheTime = 1000, $wantHQ = false);
				} // end if strlen

				if (strlen($img_teaser) > 0) {
					$teaser_img = '<img src="'.$img_teaser.'" class="teaser_img">';
				} else {
					$teaser_img = '';
				}

			} // end if noimg 		

			$headline = strip_tags($article->getContent('CMS_HTMLHEAD', 1));
			$headline = str_replace($replace, " ", $headline);

			/*			$subheadline = strip_tags($article->getContent('CMS_HTMLHEAD', 2));
						$subheadline = str_replace($replace, " ", $subheadline);*/

			$teaserheadline = /*$subheadline."&nbsp;-&nbsp;".*/
			$headline;
			$href = $sess->url("front_content.php?idcat=$selcat&idart=$article_id");
			$teasertext = $article->getField('summary');

			if (strlen(trim($teasertext)) == 0) {
				$teasertext = strip_tags($article->getContent('CMS_HTML', 1));
				$teasertext2 = $teasertext;
				$teasertext = capiStrTrimAfterWord($teasertext, $mxtext);
				if ($teasertext!=$teasertext2) {
					$teasertext.= '...';
				}
				
			} // end if   			

			$teasertext = $teasertext."&nbsp;";

			$tpl->set('d', 'HEADLINE', $teaserheadline);
			$tpl->set('d', 'TEXT', $teasertext);
			$tpl->set('d', 'HREF', $href);
			$tpl->set('d', 'IMG', $teaser_img);
			$tpl->set('d', 'MORE', mi18n("mehr"));

$oUser = new User;
$oUser->loadUserByUsername($article->getField('publishedby'));
$pub = date('d.m.Y', strtotime($article->getField('published')));

			$tpl->set('d', 'PUBLISHED',    htmlspecialchars($pub) );
			$tpl->set('d', 'PUBLISHED_BY', htmlspecialchars($oUser->getField('realname')) );


			$tpl->next();

		} // end for

		$tpl->generate('templates/'.$template);

	}
}
?>

anubis2k
Beiträge: 50
Registriert: Fr 27. Jul 2007, 13:39
Kontaktdaten:

Beitrag von anubis2k » So 11. Mai 2008, 17:01

Meinen besten Dank an dich delinquent,
jetzt funktioniert es :-)

delinquent
Beiträge: 184
Registriert: Fr 17. Aug 2007, 12:15
Kontaktdaten:

Beitrag von delinquent » Mo 12. Mai 2008, 09:43

anubis2k hat geschrieben:Meinen besten Dank an dich delinquent,
jetzt funktioniert es :-)
Ich geb auch Kurse. :-)
War nur Spaß...

Gruß,
Manuel

Gesperrt