Problem mit Datumsanzeige beim Modul NEWS

Gesperrt
donner_blitz
Beiträge: 103
Registriert: Mi 28. Sep 2005, 08:50
Kontaktdaten:

Problem mit Datumsanzeige beim Modul NEWS

Beitrag von donner_blitz » Mo 27. Feb 2006, 09:08

Beim doppeltem Einsatz des Moduls NEWS gibt es ein Problem bei der Datumsanzeige. Sobald das Modul zweimal eingestzt wird, erscheint nicht mehr das richtige Datum.

Hier zunächst der Code für die Datumsanzeige

Code: Alles auswählen

$lastmod_date = strtotime($aValue["LastModified"]); 
$lastmod_date = date('d.m.Y ', $lastmod_date );
Angezeigt werden soll das Datum der Erstellung. Das passiert auch, sobald das Modul nur einmal eingesetzt wird. Wenn aber das Modul nun zweimal eingesetzt wird, dann wird bei der Ausgabe des DATUMs plötzlich das aktuelle Tagesdatum angezeigt.

Hat jemand eine Idee woran das liegen könnte?

Hier als Ergänzung der gesamte Code der NEWS Ausgabe:

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('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]";
//echo "sel $selcat<br>";
$template = "teaser-standard.html";
//echo "tpl $template<br>";
// anzahl der zeichen text
$mxtext = 200;

$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';
}

$newsheadline = "CMS_VALUE[4]";

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

if (strlen($selcat) > 0 AND $selcat != '0') {
	$options = array ('idcat' => $selcat, "start" => false, "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

$lastmod_date = strtotime($aValue["LastModified"]); 
$lastmod_date = date('d.m.Y', $lastmod_date );

			$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', 'DATE', $lastmod_date);
                           	$tpl->set('d', 'MORE', mi18n("mehr"));

			$tpl->next();

		} // end for

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

	}
}
?>
Zuletzt geändert von donner_blitz am Mo 27. Feb 2006, 17:02, insgesamt 1-mal geändert.

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

Beitrag von Halchteranerin » Mo 27. Feb 2006, 09:49

Eintraege im errorlog?
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!

donner_blitz
Beiträge: 103
Registriert: Mi 28. Sep 2005, 08:50
Kontaktdaten:

Eintrag Errorlog

Beitrag von donner_blitz » Mo 27. Feb 2006, 09:54

Halchteranerin hat geschrieben:Eintraege im errorlog?
Kein ERRORLOG mehr nötig. Nach längerem studieren habe ich den Fehler erkannt und gebannt.

Hier nun der OUTPUT:

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
* updated     :     27.02.2006
************************************************/

cInclude('classes', 'class.article.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]";
//echo "sel $selcat<br>";
$template = "teaser-inetsport.html";
//echo "tpl $template<br>";
// anzahl der zeichen text
$mxtext = 200;

$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';
}

$newsheadline = "CMS_VALUE[4]";

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

if (strlen($selcat) > 0 AND $selcat != '0') {
	$options = array ('idcat' => $selcat, "start" => false, "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'); 
                           $article_lastmod = $article->getField('lastmodified'); 
                           $article_lastmod = strtotime($article_lastmod); 
                           $article_lastmod = date('d.m.Y  H:i:s', $article_lastmod);

			
			$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', 'DATE', $article_lastmod);
                           	$tpl->set('d', 'MORE', mi18n("mehr"));

			$tpl->next();

		} // end for

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

	}
}
?>

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

Beitrag von Halchteranerin » Mo 27. Feb 2006, 17:45

und wo war nun der Fehler?
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!

donner_blitz
Beiträge: 103
Registriert: Mi 28. Sep 2005, 08:50
Kontaktdaten:

Beitrag von donner_blitz » Mo 27. Feb 2006, 17:49

Halchteranerin hat geschrieben:und wo war nun der Fehler?
Ich hatte schlichtweg vergessen ein paar Befehle noch einzusetzen, und zwar diese:

Code: Alles auswählen

$article = $list->nextArticle();
                           $article_id = $article->getField('idart'); 
                           $article_lastmod = $article->getField('lastmodified'); 
                           $article_lastmod = strtotime($article_lastmod); 
                           $article_lastmod = date('d.m.Y  H:i:s', $article_lastmod);


kenzo
Beiträge: 112
Registriert: Di 8. Jul 2003, 19:46
Kontaktdaten:

Ich kann machen was ich will, ich bekomme kein datum hin!

Beitrag von kenzo » Fr 31. Mär 2006, 17:47

bei mir erscheint das Datum mit dem Newsmodul nicht.
Weiß also nicht mehr weiter und benötige Hilfe. :roll:
Und dann habe ich noch eine große Bitte. :oops:
Wo kann ich denn einen Zeilenumbruch <br> einfügen, so dass Headline und text durch diesen getrennt werden.
Wenn ich meine News im Teaser rechts darstelle, dann stehen Headline und der Text gleich fortlaufend nebeneinander.

Vielen vielen Dank

Hier der Output:

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('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]"; 
//echo "sel $selcat<br>"; 
$template = "teaser-standard.html"; 
//echo "tpl $template<br>"; 
// anzahl der zeichen text 
$mxtext = 85; 

$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'; 
} 

$newsheadline = "CMS_VALUE[4]"; 

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

if (strlen($selcat) > 0 AND $selcat != '0') { 
   $options = array ('idcat' => $selcat, "start" => false, "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 

$lastmod_date = strtotime($aValue["LastModified"]); 
$lastmod_date = date('d.m.Y', $lastmod_date ); 

         $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', 'DATE', $lastmod_date); 
         $tpl->set('d', 'MORE', mi18n("mehr")); 

         $tpl->next(); 

      } // end for 

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

   } 
} 
?>

donner_blitz
Beiträge: 103
Registriert: Mi 28. Sep 2005, 08:50
Kontaktdaten:

Re: Ich kann machen was ich will, ich bekomme kein datum hin

Beitrag von donner_blitz » Fr 31. Mär 2006, 20:01

[quote="kenzo"]bei mir erscheint das Datum mit dem Newsmodul nicht.
Weiß also nicht mehr weiter und benötige Hilfe. :roll:
Und dann habe ich noch eine große Bitte. :oops:
Wo kann ich denn einen Zeilenumbruch <br> einfügen, so dass Headline und text durch diesen getrennt werden.
Wenn ich meine News im Teaser rechts darstelle, dann stehen Headline und der Text gleich fortlaufend nebeneinander.

Vielen vielen Dank


Nimm diesen OUTPUT, der funktioniert:

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 
* updated     :     27.02.2006 
************************************************/ 

cInclude('classes', 'class.article.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]"; 
//echo "sel $selcat<br>"; 
$template = "teaser-news.html"; 
//echo "tpl $template<br>"; 
// anzahl der zeichen text 
$mxtext = 200; 

$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'; 
} 

$newsheadline = "CMS_VALUE[4]"; 

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

if (strlen($selcat) > 0 AND $selcat != '0') { 
   $options = array ('idcat' => $selcat, "start" => false, "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'); 
                           $article_lastmod = $article->getField('lastmodified'); 
                           $article_lastmod = strtotime($article_lastmod); 
                           $article_lastmod = date('d.m.Y  H:i:s', $article_lastmod); 

          
         $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', 'DATE', $article_lastmod); 
                              $tpl->set('d', 'MORE', mi18n("mehr")); 

         $tpl->next(); 

      } // end for 

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

   } 
} 
?> 
anbei noch das Template das du dann als teaser-news.html abspeichern muss

Code: Alles auswählen

<h1 class="content">{TITLE}</h1>


<!-- BEGIN:BLOCK -->

  <table cellpadding="0" cellspacing="0" style="border-left:1px dotted #313853; border-bottom:1px dotted #313853; padding:0; border-collapse: collapse; border-right-width:0; border-top-width:0" width="100%">
    <tr>
      <td>
  <p style="margin-left: 5">
  <a class="link_news_header" href="{HREF}">{HEADLINE}</a></td>
      <td>
  <p align="right" class=text>{DATE}</td>
    </tr>
</table>
</h1>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td valign="top">
    <p style="margin-right: 10">{IMG}</td>
    <td valign="top">
      <div style="padding-bottom:10px;">
  <font class=text>{TEXT}</font> <br>
<a href="{HREF}"><img src="images/mehr.gif" border="0" alt="{MORE}" title="{MORE}"/></a><br></div>
</td>
  </tr>

</table>
<br><br>
<!-- END:BLOCK -->

das funktioniert auf jedenfall.

Haue
Beiträge: 43
Registriert: Mi 27. Okt 2004, 20:25
Wohnort: Emsland
Kontaktdaten:

Beitrag von Haue » Do 18. Mai 2006, 15:18

Verstehe ich das richtig das der Input der gleiche ist wie das News-Modul in der Beipsielkonfiguration? Dort hatte ich bisher nicht die Möglichkeit das Datum mit auszugeben

donner_blitz
Beiträge: 103
Registriert: Mi 28. Sep 2005, 08:50
Kontaktdaten:

Beitrag von donner_blitz » Do 18. Mai 2006, 15:34

Haue hat geschrieben:Verstehe ich das richtig das der Input der gleiche ist wie das News-Modul in der Beipsielkonfiguration? Dort hatte ich bisher nicht die Möglichkeit das Datum mit auszugeben
Das ist richtig. Es verändert sich doch nur die Ausgabe. Wenn Du dir den Quellcode anschaust, dann wirst du auch sehen, dass immer das Datum angezeigt wird, wann der Artikel zum letzten Mal bearbeitet wurde. Das garantiert dann auch die Aktualität deines Artikels. So kann jeder Besucher der Internetseite feststellen, wie aktuell die News ist.

Gruß donner_blitz

barneyy
Beiträge: 16
Registriert: Di 29. Mai 2007, 15:17
Wohnort: NRW
Kontaktdaten:

Datum ist drin, Bild fehlt aber

Beitrag von barneyy » Di 18. Sep 2007, 17:21

Zunächst einmal DANK an donner_blitz, versuche jetzt seit ungeschlagenen 3 Stunden dieses Newsmodul anzupassen, was mir wegen fehlender PHP-Kenntnisse echt schwer fällt.

Dank donner_blitz habe ich das Datum jetzt drin, fehlt mir im Grunde nur noch das blöde IMG im teaser.

Wenn ich einen Newsbeitrag reinsetzte und im Artikel ein Bild einfüge über tiny, dann erscheint dieses Bild lediglich in der "Detail-Ansicht" der Seite, nicht aber im Teaser in der Übersicht.

Gibt's dafür auch noch einen simplen Lösungsansatz? Habe auch schon die article-advanced von HerrB versucht, kam damit aber überhaupt nicht klar.

donner_blitz
Beiträge: 103
Registriert: Mi 28. Sep 2005, 08:50
Kontaktdaten:

Re: Datum ist drin, Bild fehlt aber

Beitrag von donner_blitz » Di 18. Sep 2007, 20:47

schick mal deinen Code für die Ausgabe zu. Ich schau dann mal drüber.
gruß donner_blitz

barneyy
Beiträge: 16
Registriert: Di 29. Mai 2007, 15:17
Wohnort: NRW
Kontaktdaten:

Anbei der Output-Code meines Moduls

Beitrag von barneyy » Mi 19. Sep 2007, 08:23

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
* updated     :     27.02.2006
************************************************/

cInclude('classes', 'class.article.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]";
//echo "sel $selcat<br>";
$template = "teaser-news.html";
//echo "tpl $template<br>";
// anzahl der zeichen text
$mxtext = 200;

$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';
}

$newsheadline = "CMS_VALUE[4]";

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

if (strlen($selcat) > 0 AND $selcat != '0') {
   $options = array ('idcat' => $selcat, "start" => false, "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');
                           $article_lastmod = $article->getField('lastmodified');
                           $article_lastmod = strtotime($article_lastmod);
                           $article_lastmod = date('d.m.Y  H:i:s', $article_lastmod);

         
         $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', 'DATE', $article_lastmod);
                              $tpl->set('d', 'MORE', mi18n("mehr"));

         $tpl->next();

      } // end for

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

   }
}
?>
Den Code habe ich allerdings auch aus diesem Beitrag entnommen.
Was beim Anzeigen des Bildes im Teaser auch noch gut wäre: Die Einstellbarkeit der Bildgröße - aber das ist ja eh schon vorgesehen im Modul.

Thx im voraus

Gesperrt