YAAL - yet another articlelist ;)

maveric2001
Beiträge: 112
Registriert: Mi 21. Jun 2006, 07:00
Wohnort: Nordhausen
Kontaktdaten:

YAAL - yet another articlelist ;)

Beitrag von maveric2001 » Di 27. Mär 2007, 13:38

vielleicht interessant fuer einige, da ich einige dinge aus anderen listen kombiniert und schick gemacht habe

Code: Alles auswählen

Liste alle Artikel unterhalb einer Kategorie auf.

moeglichkeiten
-----------------------------------------------
- kategorie auswaehlen
- sortierung nach
- sortierungsrichtung
- limit artikel pro seite
- limit anzeige artikle insgesamt
- limit zeichen fuer artikelinhalt in artikelliste
- startikel einbinden ja/nein
- ueberschrift fuer artikeliste
- formatierungsmoeglichkeit fuer option 'sortierung nach' zur anzeige in artikelliste(nur datum)
- 1. bild des artikels anzeigen
- groesse das bildes anpassen
- angabe fuer name des templatefile
- angabe fuer name des templatefile bei nicht vorhandensein von artikeln



Template-Vars
-----------------------------------------------
{TITLE} 	- Vorgabe fuer Headlinie der Artikelliste aus der Konfiguration
{SORTVALUE}	- Ausgabe der Sortierungvorgabe(Sinnvoll fuer News, da so Newsdatum angezeigt werden kann)
{HEADLINE}	- Ueberschrift des Artikels OHNE html-tags
{TEXT}		- Inhalt des Artikels OHNE html-tags und begrenzt auf konfigurierte Anzahl von Zeichen
{IMG}		- 1. Bild des Artikels
{PAGE}		- Links zu den Seiten der Artikeliste, bei mehr Artikel als des konfigurierte Limit

Code: Alles auswählen

?><?php
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname:	yaal( yet another articlelist ;) )
* Author(s):	rene hankel
* Copyright:	michse
* Created:		2007.03.27
* Version:		0.4
* based on:		modul 'News' by Andreas Lindner, 4fb
*
************************************************/

//----------------------------------------------------------------
// get vars
unset($lo_set);
$lo_set = array();
$lo_set["IdCat"]			= "CMS_VALUE[1]";
$lo_set["SortBy"]			= "CMS_VALUE[3]";
$lo_set["Headlinie"]		= "CMS_VALUE[4]";
$lo_set["ShowImg"]			= "CMS_VALUE[13]";
$lo_set["ImgWidth"]			= "CMS_VALUE[14]";
$lo_set["LimitArt"] 		= "CMS_VALUE[15]";
$lo_set["SortDir"]			= "CMS_VALUE[16]";
$lo_set["IncStartArt"]		= "CMS_VALUE[17]";
$lo_set["Template"]			= "CMS_VALUE[18]";
$lo_set["TemplateNoArt"]	= "CMS_VALUE[19]";
$lo_set["MaxArt"] 			= "CMS_VALUE[20]";
$lo_set["MaxCharContent"] 	= "CMS_VALUE[21]";
$lo_set["ImgHeight"]		= "CMS_VALUE[22]";
$lo_set["SortValueFormat"]	= "CMS_VALUE[23]";

//----------------------------------------------------------------
// default vars
$lo_default_sortby			= 'created';
$lo_default_sortdir			= 'desc';
$lo_default_template		= 'yaal.html';
$lo_default_templatenoart	= 'yaal_noart.html';
$lo_default_limitart		= 5;
$lo_default_maxart			= 50;
$lo_default_maxcharcontent	= 200;
$lo_default_imgwidth		= 200;
$lo_default_imgheight		= 200;
$lo_default_sortvalue		= '%Y.%m.%d';

//----------------------------------------------------------------
// Base settings
if( 
	($lo_set["SortBy"] != 'created') && 
	($lo_set["SortBy"] != 'lastmodified') && 
	($lo_set["SortBy"] != 'published') &&
	($lo_set["SortBy"] != 'artsort') &&
	($lo_set["SortBy"] != 'title') 
  )
{	$lo_set["SortBy"] = $lo_default_sortby;	}
if( ($lo_set["SortDir"] != 'desc') && ($lo_set["SortDir"] != 'asc') )
{	$lo_set["SortDir"] = $lo_default_sortdir;	}
if( strlen($lo_set["Template"]) == 0 )
{	$lo_set["Template"] = $lo_default_template;	}
if( strlen($lo_set["TemplateNoArt"]) == 0 )
{	$lo_set["TemplateNoArt"] = $lo_default_templatenoart;	}
if( (int)$lo_set["LimitArt"] <= 0 )
{	$lo_set["LimitArt"] = $lo_default_limitart;	}
if( (int)$lo_set["MaxArt"] <= 0 )
{	$lo_set["MaxArt"] = $lo_default_maxart;	}
if( (int)$lo_set["MaxCharContent"] < 0 )
{	$lo_set["MaxCharContent"] = $lo_default_maxcharcontent;	}
elseif( strlen($lo_set["MaxCharContent"]) == 0 )
{	$lo_set["MaxCharContent"] = 0;	}
if( (int)$lo_set["ImgWidth"] <= 0 )
{	$lo_set["ImgWidth"] = $lo_default_imgwidth;	}
if( (int)$lo_set["ImgHeight"] <= 0 )
{	$lo_set["ImgHeight"] = $lo_default_imgheight;	}
if( strlen($lo_set["SortValueFormat"]) == 0 )
{	$lo_set["SortValueFormat"] = $lo_default_sortvalue;	}



echo '<table cellpadding="0" cellspacing="0" border="0">'."\n";

//----------------------------------------------------------------
// kategorie auswaehlen
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px">'.mi18n("Select category").': </td>'."\n";
echo '	<td class="text_medium" style="padding:5px">';
			echo buildCategorySelect("CMS_VAR[1]", $lo_set["IdCat"]);
echo '		&nbsp;<input type="image" src="images/submit.gif">';
echo '	</td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";

//----------------------------------------------------------------
// sortierung nach ...
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Sort by").':</td>'."\n";
echo '	<td class="text_medium" style="padding:5px">';
echo '		<select name="CMS_VAR[3]">'."\n";
	// erstellungszeit
	if( ($lo_set["SortBy"] == '') || ($lo_set["SortBy"] == 'created') ) 
	{	echo '<option value="created" selected>'.mi18n("Add Date").'</option>'."\n";	} 
	else 
	{	echo '<option value="created">'.mi18n("Add Date").'</option>'."\n";	}
	// letzte aenderung
	if( $lo_set["SortBy"] == 'lastmodified' ) 
	{	echo '<option value="lastmodified" selected>'.mi18n("Last Modified Date").'</option>'."\n";	} 
	else 
	{	echo '<option value="lastmodified">'.mi18n("Last Modified Date").'</option>'."\n";	}
	// veroeffentlichungs datum
	if( $lo_set["SortBy"] == 'published' ) 
	{	echo '<option value="published" selected>'.mi18n("Published Date").'</option>'."\n";	} 
	else 
	{	echo '<option value="published">'.mi18n("Published Date").'</option>'."\n";	}
	// artikelsorierung
	if( $lo_set["SortBy"] == 'artsort' ) 
	{	echo '<option value="artsort" selected>'.mi18n("Articlesort").'</option>'."\n";	} 
	else 
	{	echo '<option value="artsort">'.mi18n("Articlesort").'</option>'."\n";	}
	// title
	if( $lo_set["SortBy"] == 'title' ) 
	{	echo '<option value="title" selected>'.mi18n("Title").'</option>'."\n";	} 
	else 
	{	echo '<option value="title">'.mi18n("Title").'</option>'."\n";	}
echo '		</select>'."\n";
echo '	</td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// sortierungsrichtung
echo '</tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("ascending sorting").':</td>'."\n";
echo '	<td style="padding:5px;">'."\n";
			if( strtolower($lo_set["SortDir"]) == 'desc' ) 
			{	echo '<input type="radio" name="CMS_VAR[16]" value="asc"/>'."\n";	} 
			else 
			{	echo '<input type="radio" name="CMS_VAR[16]" value="asc" checked/>'."\n";	}
echo '	</td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("descending sorting").':</td>'."\n";
echo '	<td style="padding:5px;">'."\n";
			if( strtolower($lo_set["SortDir"]) == 'desc' ) 
			{	echo '<input type="radio" name="CMS_VAR[16]" value="desc" checked/>'."\n";	} 
			else 
			{	echo '<input type="radio" name="CMS_VAR[16]" value="desc"/>'."\n";	}
echo '	</td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";

//----------------------------------------------------------------
// Number of articles
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Limit of article per site").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[15]" value="'.$lo_set["LimitArt"].'"></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Show max article").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[20]" value="'.$lo_set["MaxArt"].'"></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Show max char for content").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[21]" value="'.$lo_set["MaxCharContent"].'"></td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";

//----------------------------------------------------------------
// Include start article
echo '<tr>'."\n";
echo '<td class="text_medium" style="padding:5px;">'.mi18n("Include startarticle in list").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="checkbox" name="CMS_VAR[17]" value="true"';
			if( $lo_set["IncStartArt"] == 'true' )
			{	echo ' checked';	}
echo '></td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";

//----------------------------------------------------------------
// ueberschrift
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Headline").': </td>'."\n";
echo '	<td class="text_medium" style="padding:5px;"><input type="text" name="CMS_VAR[4]" value="'.$lo_set["Headlinie"].'">';
echo '		<span style="font-weight: bold; font-size: 90%;">{TITLE}</span>';
echo '	</td>'."\n";
echo '</tr>'."\n";
// format fuer anzeige datumssortierung
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Format 'sort by'").':</td>'."\n";
echo '	<td class="text_medium" style="padding:5px;"><input type="text" name="CMS_VAR[23]" value="'.$lo_set["SortValueFormat"].'">';
echo '		<span style="font-weight: bold; font-size: 90%;">{SORTVALUE}</span>';
echo '	</td>'."\n";
echo '</tr>'."\n";


//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";


//----------------------------------------------------------------
// einstellung zu bildern
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("show first image of article in list").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="checkbox" name="CMS_VAR[13]" value="true"';
			if( $lo_set["ShowImg"] == 'true' )
			{	echo ' checked';	}
echo '></td>'."\n";
echo '</tr>'."\n";
// bildbreite
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Image width").': </td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[14]" value="'.$lo_set["ImgWidth"].'" maxlength="3">px</td>'."\n";
echo '</tr>'."\n";
// bildhoehe
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Image height").': </td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[22]" value="'.$lo_set["ImgHeight"].'" maxlength="3">px</td>'."\n";
echo '</tr>'."\n";


//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";


//----------------------------------------------------------------
// templates
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Name of templatefile").': </td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[18]" value="'.$lo_set["Template"].'"></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Name of templatefile for 'no article found'").': </td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[19]" value="'.$lo_set["TemplateNoArt"].'"></td>'."\n";
echo '</tr>'."\n";

echo '</table>'."\n";
?><?php

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname:	yaal( yet another articlelist ;) )
* Author(s):	rene hankel
* Copyright:	michse
* Created:		2007.03.27
* Version:		0.4
* based on:		modul 'News' by Andreas Lindner, 4fb
*
************************************************/


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


//----------------------------------------------------------------
// get vars
unset($lo_set);
$lo_set = array();
$lo_set["IdCat"]			= "CMS_VALUE[1]";
$lo_set["SortBy"]			= "CMS_VALUE[3]";
$lo_set["Headlinie"]		= "CMS_VALUE[4]";
$lo_set["ShowImg"]			= "CMS_VALUE[13]";
$lo_set["ImgWidth"]			= "CMS_VALUE[14]";
$lo_set["LimitArt"] 		= "CMS_VALUE[15]";
$lo_set["SortDir"]			= "CMS_VALUE[16]";
$lo_set["IncStartArt"]		= "CMS_VALUE[17]";
$lo_set["Template"]			= "CMS_VALUE[18]";
$lo_set["TemplateNoArt"]	= "CMS_VALUE[19]";
$lo_set["MaxArt"] 			= "CMS_VALUE[20]";
$lo_set["MaxCharContent"] 	= "CMS_VALUE[21]";
$lo_set["ImgHeight"]		= "CMS_VALUE[22]";
$lo_set["SortValueFormat"]	= "CMS_VALUE[23]";

//----------------------------------------------------------------
// default vars
$lo_default_sortby			= 'created';
$lo_default_sortdir			= 'desc';
$lo_default_template		= 'yaal.html';
$lo_default_templatenoart	= 'yaal_noart.html';
$lo_default_limitart		= 5;
$lo_default_maxart			= 50;
$lo_default_maxcharcontent	= 200;
$lo_default_imgwidth		= 200;
$lo_default_imgheight		= 200;
$lo_default_sortvalue		= '%Y.%m.%d';

//----------------------------------------------------------------
// Base settings
if( 
	($lo_set["SortBy"] != 'created') && 
	($lo_set["SortBy"] != 'lastmodified') && 
	($lo_set["SortBy"] != 'published') &&
	($lo_set["SortBy"] != 'artsort') &&
	($lo_set["SortBy"] != 'title') 
  )
{	$lo_set["SortBy"] = $lo_default_sortby;	}
if( ($lo_set["SortDir"] != 'desc') && ($lo_set["SortDir"] != 'asc') )
{	$lo_set["SortDir"] = $lo_default_sortdir;	}
if( strlen($lo_set["Template"]) == 0 )
{	$lo_set["Template"] = $lo_default_template;	}
if( strlen($lo_set["TemplateNoArt"]) == 0 )
{	$lo_set["TemplateNoArt"] = $lo_default_templatenoart;	}
if( (int)$lo_set["LimitArt"] <= 0 )
{	$lo_set["LimitArt"] = $lo_default_limitart;	}
if( (int)$lo_set["MaxArt"] <= 0 )
{	$lo_set["MaxArt"] = $lo_default_maxart;	}
if( (int)$lo_set["MaxCharContent"] < 0 )
{	$lo_set["MaxCharContent"] = $lo_default_maxcharcontent;	}
elseif( strlen($lo_set["MaxCharContent"]) == 0 )
{	$lo_set["MaxCharContent"] = 0;	}
if( (int)$lo_set["ImgWidth"] <= 0 )
{	$lo_set["ImgWidth"] = $lo_default_imgwidth;	}
if( (int)$lo_set["ImgHeight"] <= 0 )
{	$lo_set["ImgHeight"] = $lo_default_imgheight;	}
if( strlen($lo_set["SortValueFormat"]) == 0 )
{	$lo_set["SortValueFormat"] = $lo_default_sortvalue;	}


//----------------------------------------------------------------
// lokale zusatz vars
$lo_seite = 1;
$lo_limit = 0;
$lo_articleid = 0;
$lo_page = (int)$_REQUEST['page'];
$lo_pagelnk = '';
$lo_href = '';
$lo_filename = '';
$lo_dirname= '';
$lo_teaserimghref = '';
$lo_imgname = '';
$lo_tplimg = '';
$lo_tplhref = '';
$lo_tplheadline = '';
$lo_tpltext = '';
$lo_pagearr = array();
$lo_tmparr = array();
$lo_options = array();
$lo_limitart = 0;


//----------------------------------------------------------------
// template obj erstellen
if (!is_object($lo_tpl)) 
{	$lo_tpl = new Template;	}


//----------------------------------------------------------------
// allgemeine template sachen
$lo_tpl->reset();
$lo_tpl->set('s', 'TITLE', $lo_set["Headlinie"]);



//----------------------------------------------------------------
// wenn 'idcat' vorhanden und nicht null
if( (strlen($lo_set["IdCat"]) > 0) && ((int)$lo_set["IdCat"] != 0) )   
{
	// optionsarray fur artikelabfrage erstellen
	$lo_options['idcat'] = $lo_set["IdCat"];
	if( $lo_set["IncStartArt"] == 'true' )
	{	$lo_options['start'] = true;	}
	else
	{	$lo_options['start'] = false;	}
	$lo_options['order'] = $lo_set["SortBy"];
	$lo_options['direction'] = $lo_set["SortDir"];
	
	// artikel abfragen
	$lo_artlist = new ArticleCollection($lo_options);


	//----------------------------------------------------------------
	// falls artikel vorliegen
	if ($lo_artlist->count > 0) 
	{
		//----------------------------------------------------------------
		// pruefe ob vorhanden artikelanzahl groesser ist als 
		// max angezeigt werden sollen
		if( $lo_set["MaxArt"] < $lo_artlist->count ) 
		{	$lo_limitart = $lo_set["MaxArt"];	} 
		else 
		{	$lo_limitart = $lo_artlist->count;	}

		//--------------------------------------------
		// page seiten und offset erstellen
		while( true )
		{
			// falls offset erreicht wurde, abbrechen
			if( $lo_limit >= $lo_limitart )
			{
				// damit array wenigsten 0 werte enthaelt
				if( count($lo_pagearr) == 0 )
				{	$lo_pagearr[1] = 0;}
				break;
			}
			// neue seite mit zugehoerigen offset einfuegen
			$lo_pagearr[$lo_seite] = $lo_limit;
			// offset errechnen
			$lo_limit += $lo_set["LimitArt"];
			// seitenzahl erhoehen
			$lo_seite += 1;
		}

		//----------------------------------------------------------------
		// pruefe ob var 'page' in den moeglichen seitenangaben existiert
		if( array_key_exists($lo_page, $lo_pagearr) )
		{}
		else 
		{	$lo_page = 1;	}


		//----------------------------------------------------------------
		// durchlaufe alle gefundenen artikel
		for( $i = 0; $i < $lo_limitart; $i++ ) 
		{
			// hole naechsten artikel
			$lo_article = $lo_artlist->nextArticle();
//echo $lo_page.'<pre>';print_r($lo_article);echo '</pre>';

			//----------------------------------------------------------------
			// zeige artikel an, wenn er innerhalb der zu zeigenden page liegt
			if( ($i >= $lo_pagearr[$lo_page]) && ($i <($lo_pagearr[$lo_page]+$lo_set["LimitArt"])) )
			{
				$lo_articleid = $lo_article->getField('idart');
	
				$lo_tplimg = '';

				//----------------------------------------------------------------
				// falls bild angezeigt werden soll
				if( $lo_set["ShowImg"] == 'true' ) 
				{
					// hole artikelinhalt
					$text_html = $lo_article->getContent('CMS_HTML', 1);
	
					// suche nach bildern
					$regEx = "/<img[^>]*?>.*?/i";
					$match = array ();
					preg_match($regEx, $text_html, $match);
	
					// suche nach bildquelle und splite pfad auf
					$regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
					$img = array ();
					preg_match($regEx, $match[0], $img);
					$img_src = preg_split("/\//", $img[0]);
	
					// finde dateinanem ohne endung
					$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]);
	
					$lo_imgname = $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;
							$lo_imgname = preg_replace("/$suffix/", "", $img_name);
							$lo_imgname = $lo_imgname.".[a-zA-Z]{3}";
						}
					}
	
					$lo_teaserimghref = '';
	
					//----------------------------------------------------------------
					// bild vorhanden ist vorhanden
					if( strlen($lo_imgname) > 0 ) 
					{
						$sql = 'SELECT * FROM '.$cfg["tab"]["upl"].' WHERE filename REGEXP \''.$lo_imgname.'\'';
						$db->query($sql);

						// bild info abfragen	
						if ($db->next_record()) 
						{
							$lo_filename = $db->f('filename');
							$lo_dirname = $db->f('dirname');
						}

						// dateipfad zusammensetzen
						$img_path = $cfgClient[$client]["upl"]["path"].$lo_dirname.$lo_filename;
						// href des bildes erzeugen
						$lo_teaserimghref = capiImgScale($img_path, $lo_set["ImgWidth"], $lo_set["ImgHeight"], $crop = false, $expand = false, $cacheTime = 1000, $wantHQ = false);

					} // end if strlen
	
					//----------------------------------------------------------------
					// falls href des bildes gefunden
					if (strlen($lo_teaserimghref) > 0) 
					{	$lo_tplimg = '<img src="'.$lo_teaserimghref.'" alt="'.$lo_imgname.'">';	} 
					else 
					{	$lo_tplimg = '';	}
	
				} // end if noimg 		
	
				// html-tags entfernen
				$lo_tplheadline = strip_tags($lo_article->getContent('CMS_HTMLHEAD', 1));
				$lo_tplheadline = str_replace($replace, " ", $lo_tplheadline);
	
	
				$lo_tplhref = $sess->url('front_content.php?idcat='.$lo_set["IdCat"].'&idart='.$lo_articleid);
				$lo_tpltext = $lo_article->getField('summary');

				//----------------------------------------------------------------
				if (strlen(trim($lo_tpltext)) == 0) 
				{
					$lo_tpltext = strip_tags($lo_article->getContent('CMS_HTML', 1));
					// wenn text laenger als gewuenscht ist
					if( strlen($lo_tpltext) > $lo_set["MaxCharContent"] )
					{
						// wenn text angezeigt werden soll
						if( (int)$lo_set["MaxCharContent"] > 0 )
						{
							$lo_tpltext  = capiStrTrimAfterWord($lo_tpltext, (int)$lo_set["MaxCharContent"]);
							$lo_tpltext .= '...';
						}
						else 
						{	$lo_tpltext = '';	}
					}
				} // end if   			
				$lo_tpltext = $lo_tpltext.'&nbsp;';
				



				// wenn sortierungsoption zeitwert ist, dann formatieren
				if( ($lo_set["SortBy"] == 'created') || ($lo_set["SortBy"] == 'lastmodified') || ($lo_set["SortBy"] == 'published') )
				{	$lo_tpl->set('d', 'SORTVALUE', strftime($lo_set["SortValueFormat"], strtotime($lo_article->getField($lo_set["SortBy"]))) );	}
				else
				{	$lo_tpl->set('d', 'SORTVALUE', $lo_article->getField($lo_set["SortBy"]) );	}
				// andere templatevars
				$lo_tpl->set('d', 'HEADLINE', $lo_tplheadline);
				$lo_tpl->set('d', 'TEXT', $lo_tpltext);
				$lo_tpl->set('d', 'HREF', $lo_tplhref);
				$lo_tpl->set('d', 'IMG', $lo_tplimg);
	
				$lo_tpl->next();
	
			} // end for
		}
		
		//----------------------------------------------------------------
		// pagelinks erstellen
		foreach( $lo_pagearr as $lo_key => $lo_value) 
		{
			$lo_href = $sess->url('front_content.php?idcat='.$lo_set["IdCat"].'&page='.$lo_key);
			if( $lo_page == $lo_key )
			{	$lo_pagelnk .= '<strong>'.$lo_key.'</strong>&nbsp;&nbsp;';	}
			else
			{	$lo_pagelnk .= '<a href="'.$lo_href.'">'.$lo_key.'</a>&nbsp;&nbsp;';	}
		}

		$lo_tpl->set('s', 'PAGE', $lo_pagelnk);
		$lo_tpl->generate('templates/'.$lo_set["Template"]);

	}
	//----------------------------------------------------------------
	// keine artikel vorhanden
	else 
	{
		$lo_tpl->generate('templates/'.$lo_set["TemplateNoArt"]);
	}
}
?>
hier noch mein template, auch wenn´s euch nichts nuetzt

Code: Alles auswählen

<table border="0" cellspacing="0" cellpadding="0">
<tr>
	<td>
		<div>
			<div>
				{TITLE}
			</div>
		</div>
<!-- BEGIN:BLOCK -->
		<div>
			<img src="images/arrow_gray.jpg" ALT="">
				<span>{SORTVALUE}</span>&nbsp;
				<a href="{HREF}" >{HEADLINE}</a><br>
				{TEXT}<br>
				{IMG}
		</div>
		<div><img src="images/spacer.gif" height="1" width="1" ALT=""></div>
<!-- END:BLOCK -->
	</td>
</tr>
<tr>
	<td >
		<div>
			<div>
				Seite(n):&nbsp;{PAGE}
			</div>
		</div>
	</td>
</tr>
</table>

ippkem
Beiträge: 10
Registriert: Do 21. Dez 2006, 22:04
Kontaktdaten:

Beitrag von ippkem » Mi 28. Mär 2007, 22:04

Hallo maveric2001!

Habe als User ohne php-Kenntnisse Deinen Code ausprobiert. Hat auf Anhieb gut funktioniert!

*

Beim Generieren von {Content} werden Zeilenumbrüche weggelassen. Dadurch kommt es zu unschönen Aneinanderreihungen. Wie kann man statt des Weglassens der Zeilenumbrüche ein Leerzeichen bekommen? (Noch besser wäre ein konfigurierbarer String als Ersatz für die Zeilenumbrüche ...)

*

Praktisch wäre es, für "Headline" = {title} neben der manuellen Deklaration auch automatisch den Kategorienamen übernehmen zu können. Ließe sich das noch einbauen?

Grüße
ippkem

maveric2001
Beiträge: 112
Registriert: Mi 21. Jun 2006, 07:00
Wohnort: Nordhausen
Kontaktdaten:

Beitrag von maveric2001 » Do 29. Mär 2007, 07:54

muss ich schaun, bau gerade den filter fuer artikelspezifikationen

maveric2001
Beiträge: 112
Registriert: Mi 21. Jun 2006, 07:00
Wohnort: Nordhausen
Kontaktdaten:

Beitrag von maveric2001 » Do 29. Mär 2007, 10:56

ippkem hat geschrieben:Hallo maveric2001!

Habe als User ohne php-Kenntnisse Deinen Code ausprobiert. Hat auf Anhieb gut funktioniert!
sehr gut
ippkem hat geschrieben: Beim Generieren von {Content} werden Zeilenumbrüche weggelassen. Dadurch kommt es zu unschönen Aneinanderreihungen. Wie kann man statt des Weglassens der Zeilenumbrüche ein Leerzeichen bekommen? (Noch besser wäre ein konfigurierbarer String als Ersatz für die Zeilenumbrüche ...)
habe die <br> in leerzeichen umgewandelt. konfigurierbare zeichen find ich doowe. achtung, wenn du etwas in die artikel-zusammenfassung eintraegst, wird dies dargestellt. so gesehen eine gute alternative
ippkem hat geschrieben:Praktisch wäre es, für "Headline" = {title} neben der manuellen Deklaration auch automatisch den Kategorienamen übernehmen zu können. Ließe sich das noch einbauen?
liesse sich. im gegensatz zum einmaligen eintragens per aber zu aufwendig, da erneute sql-abfrage noetig waere

Code: Alles auswählen

Liste alle Artikel unterhalb einer Kategorie auf.

moeglichkeiten
-----------------------------------------------
- kategorie auswaehlen
- sortierung nach
- sortierungsrichtung
- limit artikel pro seite
- limit anzeige artikle insgesamt
- limit zeichen fuer artikelinhalt in artikelliste
- filter fuer artikelspezifikation(mandanten -> artikel spezifikationen)
- startikel einbinden ja/nein
- ueberschrift fuer artikeliste
- formatierungsmoeglichkeit fuer option 'sortierung nach' zur anzeige in artikelliste(nur datum)
- 1. bild des artikels anzeigen
- groesse das bildes anpassen
- angabe fuer name des templatefile
- angabe fuer name des templatefile bei nicht vorhandensein von artikeln



Template-Vars
-----------------------------------------------
{TITLE} 	- Vorgabe fuer Headlinie der Artikelliste aus der Konfiguration
{SORTVALUE}	- Ausgabe der Sortierungvorgabe(Sinnvoll fuer News, da so Newsdatum angezeigt werden kann)
{HEADLINE}	- Ueberschrift des Artikels OHNE html-tags
{TEXT}		- Inhalt des Artikels OHNE html-tags und begrenzt auf konfigurierte Anzahl von Zeichen
				!!!ACHTUNG!!! - wenn der artkel eine zusammenfassung besitzt wird diese komplett ausgegeben
{IMG}		- 1. Bild des Artikels
{PAGE}		- Links zu den Seiten der Artikeliste, bei mehr Artikel als des konfigurierte Limit

Code: Alles auswählen

?><?php
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname:	yaal( yet another articlelist ;) )
* Author(s):	rene hankel
* Copyright:	michse
* Created:		2007.03.29
* Version:		0.5
* based on:		modul 'News' by Andreas Lindner, 4fb
*
************************************************/


//----------------------------------------------------------------
// get vars
unset($lo_set);
$lo_set = array();
$lo_set["IdCat"]			= "CMS_VALUE[1]";
$lo_set["SortBy"]			= "CMS_VALUE[3]";
$lo_set["Headlinie"]		= "CMS_VALUE[4]";
$lo_set["ShowImg"]			= "CMS_VALUE[13]";
$lo_set["ImgWidth"]			= "CMS_VALUE[14]";
$lo_set["LimitArt"] 		= "CMS_VALUE[15]";
$lo_set["SortDir"]			= "CMS_VALUE[16]";
$lo_set["IncStartArt"]		= "CMS_VALUE[17]";
$lo_set["Template"]			= "CMS_VALUE[18]";
$lo_set["TemplateNoArt"]	= "CMS_VALUE[19]";
$lo_set["MaxArt"] 			= "CMS_VALUE[20]";
$lo_set["MaxCharContent"] 	= "CMS_VALUE[21]";
$lo_set["ImgHeight"]		= "CMS_VALUE[22]";
$lo_set["SortValueFormat"]	= "CMS_VALUE[23]";
$lo_set["Filter"]			= "CMS_VALUE[24]";

//----------------------------------------------------------------
// default vars
$lo_default_sortby			= 'created';
$lo_default_sortdir			= 'desc';
$lo_default_template		= 'yaal.html';
$lo_default_templatenoart	= 'yaal_noart.html';
$lo_default_limitart		= 5;
$lo_default_maxart			= 50;
$lo_default_maxcharcontent	= 200;
$lo_default_imgwidth		= 200;
$lo_default_imgheight		= 200;
$lo_default_sortvalue		= '%Y.%m.%d';
$lo_filter_seperator		= '<~>';

//----------------------------------------------------------------
// Base settings
if( 
	($lo_set["SortBy"] != 'created') && 
	($lo_set["SortBy"] != 'lastmodified') && 
	($lo_set["SortBy"] != 'published') &&
	($lo_set["SortBy"] != 'artsort') &&
	($lo_set["SortBy"] != 'title') 
  )
{	$lo_set["SortBy"] = $lo_default_sortby;	}
if( ($lo_set["SortDir"] != 'desc') && ($lo_set["SortDir"] != 'asc') )
{	$lo_set["SortDir"] = $lo_default_sortdir;	}
if( strlen($lo_set["Template"]) == 0 )
{	$lo_set["Template"] = $lo_default_template;	}
if( strlen($lo_set["TemplateNoArt"]) == 0 )
{	$lo_set["TemplateNoArt"] = $lo_default_templatenoart;	}
if( (int)$lo_set["LimitArt"] <= 0 )
{	$lo_set["LimitArt"] = $lo_default_limitart;	}
if( (int)$lo_set["MaxArt"] <= 0 )
{	$lo_set["MaxArt"] = $lo_default_maxart;	}
if( (int)$lo_set["MaxCharContent"] < 0 )
{	$lo_set["MaxCharContent"] = $lo_default_maxcharcontent;	}
elseif( strlen($lo_set["MaxCharContent"]) == 0 )
{	$lo_set["MaxCharContent"] = 0;	}
if( (int)$lo_set["ImgWidth"] <= 0 )
{	$lo_set["ImgWidth"] = $lo_default_imgwidth;	}
if( (int)$lo_set["ImgHeight"] <= 0 )
{	$lo_set["ImgHeight"] = $lo_default_imgheight;	}
if( strlen($lo_set["SortValueFormat"]) == 0 )
{	$lo_set["SortValueFormat"] = $lo_default_sortvalue;	}
// serialisierte var exploden, wenn vorhanden
if( strlen($lo_set["Filter"]) == 0 )
{	$lo_tmparr_cms = array();	}
else 
{	$lo_tmparr_cms = (explode($lo_filter_seperator, "CMS_VALUE[24]"));	}


//----------------------------------------------------------------
// script zum serialisieren
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function Func_GenerateSerialize(lo_obj)
{ 
	lo_run = 0;
	lo_tmp = '';
	lo_sep = '<?PHP echo $lo_filter_seperator;?>';
   
	// return multiselect array as string
	if ( !lo_obj ) 
	{ 
		return (lo_tmp);
	}
	for(lo_run = 0; lo_run < lo_obj.length; lo_run++)
   	{
		if ( lo_obj.options[lo_run].selected == true )
		{
			lo_tmp += (lo_tmp > '' ? lo_sep: '') + lo_obj.options[lo_run].value;
		}
   	}
	return (lo_tmp);
}
-->
</script>
<?PHP

//----------------------------------------------------------------
// db-obj erstellen
if ( !is_object($lo_dbobj) ) 
{	$lo_dbobj = new DB_Contenido;	}

//----------------------------------------------------------------
// artikelspezifikationen abfragen
$lo_sql = 'SELECT SPEC.idartspec, SPEC.artspec, SPEC.client, SPEC.lang ';
$lo_sql.= 'FROM '.$cfg['tab']['art_spec'].' AS SPEC ';
$lo_sql.= 'WHERE SPEC.client = \''.$client.'\' ';
$lo_sql.= 'AND SPEC.lang = \''.$lang.'\' ';
$lo_sql.= 'AND SPEC.online = \'1\' ';
$lo_sql.= 'ORDER BY SPEC.idartspec asc';
// abfrage ausfuehren
$lo_dbobj->query($lo_sql);


echo '<table cellpadding="0" cellspacing="0" border="0">'."\n";

//----------------------------------------------------------------
// kategorie auswaehlen
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px">'.mi18n("Select category").': </td>'."\n";
echo '	<td class="text_medium" style="padding:5px">';
			echo buildCategorySelect("CMS_VAR[1]", $lo_set["IdCat"]);
echo '		&nbsp;<input type="image" src="images/submit.gif">';
echo '	</td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";

//----------------------------------------------------------------
// sortierung nach ...
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Sort by").':</td>'."\n";
echo '	<td class="text_medium" style="padding:5px">';
echo '		<select name="CMS_VAR[3]">'."\n";
	// erstellungszeit
	if( ($lo_set["SortBy"] == '') || ($lo_set["SortBy"] == 'created') ) 
	{	echo '<option value="created" selected>'.mi18n("Add Date").'</option>'."\n";	} 
	else 
	{	echo '<option value="created">'.mi18n("Add Date").'</option>'."\n";	}
	// letzte aenderung
	if( $lo_set["SortBy"] == 'lastmodified' ) 
	{	echo '<option value="lastmodified" selected>'.mi18n("Last Modified Date").'</option>'."\n";	} 
	else 
	{	echo '<option value="lastmodified">'.mi18n("Last Modified Date").'</option>'."\n";	}
	// veroeffentlichungs datum
	if( $lo_set["SortBy"] == 'published' ) 
	{	echo '<option value="published" selected>'.mi18n("Published Date").'</option>'."\n";	} 
	else 
	{	echo '<option value="published">'.mi18n("Published Date").'</option>'."\n";	}
	// artikelsorierung
	if( $lo_set["SortBy"] == 'artsort' ) 
	{	echo '<option value="artsort" selected>'.mi18n("Articlesort").'</option>'."\n";	} 
	else 
	{	echo '<option value="artsort">'.mi18n("Articlesort").'</option>'."\n";	}
	// title
	if( $lo_set["SortBy"] == 'title' ) 
	{	echo '<option value="title" selected>'.mi18n("Title").'</option>'."\n";	} 
	else 
	{	echo '<option value="title">'.mi18n("Title").'</option>'."\n";	}
echo '		</select>'."\n";
echo '	</td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// sortierungsrichtung
echo '</tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("ascending sorting").':</td>'."\n";
echo '	<td style="padding:5px;">'."\n";
			if( strtolower($lo_set["SortDir"]) == 'desc' ) 
			{	echo '<input type="radio" name="CMS_VAR[16]" value="asc"/>'."\n";	} 
			else 
			{	echo '<input type="radio" name="CMS_VAR[16]" value="asc" checked/>'."\n";	}
echo '	</td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("descending sorting").':</td>'."\n";
echo '	<td style="padding:5px;">'."\n";
			if( strtolower($lo_set["SortDir"]) == 'desc' ) 
			{	echo '<input type="radio" name="CMS_VAR[16]" value="desc" checked/>'."\n";	} 
			else 
			{	echo '<input type="radio" name="CMS_VAR[16]" value="desc"/>'."\n";	}
echo '	</td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";

//----------------------------------------------------------------
// Number of articles
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Limit of article per site").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[15]" value="'.$lo_set["LimitArt"].'"></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Show max article").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[20]" value="'.$lo_set["MaxArt"].'"></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Show max char for content").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[21]" value="'.$lo_set["MaxCharContent"].'"></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;" valign="top">'.mi18n("Filter articlespecification").':</td>'."\n";
echo '	<td style="padding:5px;">';
echo '		<input id="CMS_VAR24" type="hidden" name="CMS_VAR[24]" value="">'."\n";
// uppsi keine artikelspezifikation vorhanden
if( !$lo_dbobj->num_rows() )
{	echo mi18n("no articelspecification available");	}
else 
{
	echo '<select size="5" multiple onchange="javascript:document.getElementById(\'CMS_VAR24\').value=Func_GenerateSerialize(this);">'."\n";
	while( $lo_dbobj->next_record() )
	{
		echo '<option value="'.$lo_dbobj->f('idartspec').'"';
		if( in_array($lo_dbobj->f('idartspec'), $lo_tmparr_cms) )
		{	echo ' selected';	}
		echo '>'.$lo_dbobj->f('artspec').'</option>'."\n";
	}
	echo '</select>'."\n";
}

echo '	</td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";

//----------------------------------------------------------------
// Include start article
echo '<tr>'."\n";
echo '<td class="text_medium" style="padding:5px;">'.mi18n("Include startarticle in list").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="checkbox" name="CMS_VAR[17]" value="true"';
			if( $lo_set["IncStartArt"] == 'true' )
			{	echo ' checked';	}
echo '></td>'."\n";
echo '</tr>'."\n";

//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";

//----------------------------------------------------------------
// ueberschrift
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Headline").': </td>'."\n";
echo '	<td class="text_medium" style="padding:5px;"><input type="text" name="CMS_VAR[4]" value="'.$lo_set["Headlinie"].'">';
echo '		<span style="font-weight: bold; font-size: 90%;">{TITLE}</span>';
echo '	</td>'."\n";
echo '</tr>'."\n";
// format fuer anzeige datumssortierung
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Format 'sort by'").':</td>'."\n";
echo '	<td class="text_medium" style="padding:5px;"><input type="text" name="CMS_VAR[23]" value="'.$lo_set["SortValueFormat"].'">';
echo '		<span style="font-weight: bold; font-size: 90%;">{SORTVALUE}</span>';
echo '	</td>'."\n";
echo '</tr>'."\n";


//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";


//----------------------------------------------------------------
// einstellung zu bildern
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("show first image of article in list").':</td>'."\n";
echo '	<td style="padding:5px;"><input type="checkbox" name="CMS_VAR[13]" value="true"';
			if( $lo_set["ShowImg"] == 'true' )
			{	echo ' checked';	}
echo '></td>'."\n";
echo '</tr>'."\n";
// bildbreite
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Image width").': </td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[14]" value="'.$lo_set["ImgWidth"].'" maxlength="3">px</td>'."\n";
echo '</tr>'."\n";
// bildhoehe
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Image height").': </td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[22]" value="'.$lo_set["ImgHeight"].'" maxlength="3">px</td>'."\n";
echo '</tr>'."\n";


//----------------------------------------------------------------
// trennlinie
echo '<tr><td colspan="2"><hr></td></tr>'."\n";


//----------------------------------------------------------------
// templates
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Name of templatefile").': </td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[18]" value="'.$lo_set["Template"].'"></td>'."\n";
echo '</tr>'."\n";
echo '<tr>'."\n";
echo '	<td class="text_medium" style="padding:5px;">'.mi18n("Name of templatefile for 'no article found'").': </td>'."\n";
echo '	<td style="padding:5px;"><input type="text" name="CMS_VAR[19]" value="'.$lo_set["TemplateNoArt"].'"></td>'."\n";
echo '</tr>'."\n";

echo '</table>'."\n";
?><?php

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname:	yaal( yet another articlelist ;) )
* Author(s):	rene hankel
* Copyright:	michse
* Created:		2007.03.29
* Version:		0.5
* based on:		modul 'News' by Andreas Lindner, 4fb
*
************************************************/


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


//----------------------------------------------------------------
// get vars
unset($lo_set);
$lo_set = array();
$lo_set["IdCat"]			= "CMS_VALUE[1]";
$lo_set["SortBy"]			= "CMS_VALUE[3]";
$lo_set["Headlinie"]		= "CMS_VALUE[4]";
$lo_set["ShowImg"]			= "CMS_VALUE[13]";
$lo_set["ImgWidth"]			= "CMS_VALUE[14]";
$lo_set["LimitArt"] 		= "CMS_VALUE[15]";
$lo_set["SortDir"]			= "CMS_VALUE[16]";
$lo_set["IncStartArt"]		= "CMS_VALUE[17]";
$lo_set["Template"]			= "CMS_VALUE[18]";
$lo_set["TemplateNoArt"]	= "CMS_VALUE[19]";
$lo_set["MaxArt"] 			= "CMS_VALUE[20]";
$lo_set["MaxCharContent"] 	= "CMS_VALUE[21]";
$lo_set["ImgHeight"]		= "CMS_VALUE[22]";
$lo_set["SortValueFormat"]	= "CMS_VALUE[23]";
$lo_set["Filter"]			= "CMS_VALUE[24]";

//----------------------------------------------------------------
// default vars
$lo_default_sortby			= 'created';
$lo_default_sortdir			= 'desc';
$lo_default_template		= 'yaal.html';
$lo_default_templatenoart	= 'yaal_noart.html';
$lo_default_limitart		= 5;
$lo_default_maxart			= 50;
$lo_default_maxcharcontent	= 200;
$lo_default_imgwidth		= 200;
$lo_default_imgheight		= 200;
$lo_default_sortvalue		= '%Y.%m.%d';
$lo_filter_seperator		= '<~>';

//----------------------------------------------------------------
// Base settings
if( 
	($lo_set["SortBy"] != 'created') && 
	($lo_set["SortBy"] != 'lastmodified') && 
	($lo_set["SortBy"] != 'published') &&
	($lo_set["SortBy"] != 'artsort') &&
	($lo_set["SortBy"] != 'title') 
  )
{	$lo_set["SortBy"] = $lo_default_sortby;	}
if( ($lo_set["SortDir"] != 'desc') && ($lo_set["SortDir"] != 'asc') )
{	$lo_set["SortDir"] = $lo_default_sortdir;	}
if( strlen($lo_set["Template"]) == 0 )
{	$lo_set["Template"] = $lo_default_template;	}
if( strlen($lo_set["TemplateNoArt"]) == 0 )
{	$lo_set["TemplateNoArt"] = $lo_default_templatenoart;	}
if( (int)$lo_set["LimitArt"] <= 0 )
{	$lo_set["LimitArt"] = $lo_default_limitart;	}
if( (int)$lo_set["MaxArt"] <= 0 )
{	$lo_set["MaxArt"] = $lo_default_maxart;	}
if( (int)$lo_set["MaxCharContent"] < 0 )
{	$lo_set["MaxCharContent"] = $lo_default_maxcharcontent;	}
elseif( strlen($lo_set["MaxCharContent"]) == 0 )
{	$lo_set["MaxCharContent"] = 0;	}
if( (int)$lo_set["ImgWidth"] <= 0 )
{	$lo_set["ImgWidth"] = $lo_default_imgwidth;	}
if( (int)$lo_set["ImgHeight"] <= 0 )
{	$lo_set["ImgHeight"] = $lo_default_imgheight;	}
if( strlen($lo_set["SortValueFormat"]) == 0 )
{	$lo_set["SortValueFormat"] = $lo_default_sortvalue;	}
// serialisierte var exploden, wenn vorhanden
if( strlen($lo_set["Filter"]) == 0 )
{	$lo_tmparr_cms = array();	}
else 
{	$lo_tmparr_cms = (explode($lo_filter_seperator, "CMS_VALUE[24]"));	}


//----------------------------------------------------------------
// lokale zusatz vars
$lo_seite = 1;
$lo_limit = 0;
$lo_articleid = 0;
$lo_page = (int)$_REQUEST['page'];
$lo_pagelnk = '';
$lo_href = '';
$lo_filename = '';
$lo_dirname= '';
$lo_teaserimghref = '';
$lo_imgname = '';
$lo_tplimg = '';
$lo_tplhref = '';
$lo_tplheadline = '';
$lo_tpltext = '';
$lo_pagearr = array();
$lo_tmparr = array();
$lo_transarr = array ('<br>' => ' ', '<BR>' => ' ','<br/>' => ' ','<br />' => ' ','<BR/>' => ' ', '<BR />' => ' ');
$lo_options = array();
$lo_limitart = 0;


//----------------------------------------------------------------
// template obj erstellen
if (!is_object($lo_tpl)) 
{	$lo_tpl = new Template;	}
//----------------------------------------------------------------
// db-obj erstellen
if ( !is_object($lo_dbobj) ) 
{	$lo_dbobj = new DB_Contenido;	}

//----------------------------------------------------------------
// vorhanden artikelspezifikationen die online sind mit
// konfigurierten syncen
$lo_sql = 'SELECT SPEC.idartspec, SPEC.artspec, SPEC.client, SPEC.lang ';
$lo_sql.= 'FROM '.$cfg['tab']['art_spec'].' AS SPEC ';
$lo_sql.= 'WHERE SPEC.client = \''.$client.'\' ';
$lo_sql.= 'AND SPEC.lang = \''.$lang.'\' ';
$lo_sql.= 'AND SPEC.online = \'1\' ';
$lo_sql.= 'ORDER BY SPEC.idartspec asc';
// artikelspezifikationen abfragen
$lo_dbobj->query($lo_sql);
// array aus artikelspezifikationen erstellen
while( $lo_dbobj->next_record() )
{	$lo_tmparr[] = $lo_dbobj->f('idartspec');	}
// array mit den werten fuellen die die konfiguriert wurden UND
// vorhanden und online sind
$lo_tmparr_cms = array_intersect($lo_tmparr, $lo_tmparr_cms);



//----------------------------------------------------------------
// allgemeine template sachen
$lo_tpl->reset();
$lo_tpl->set('s', 'TITLE', $lo_set["Headlinie"]);

//----------------------------------------------------------------
// wenn 'idcat' vorhanden und nicht null
if( (strlen($lo_set["IdCat"]) > 0) && ((int)$lo_set["IdCat"] != 0) )   
{
	// optionsarray fur artikelabfrage erstellen
	$lo_options['idcat'] = $lo_set["IdCat"];
	// startartikel anzeigen?
	if( $lo_set["IncStartArt"] == 'true' )
	{	$lo_options['start'] = true;	}
	else
	{	$lo_options['start'] = false;	}
	// sortierung
	$lo_options['order'] = $lo_set["SortBy"];
	// sortierungsrichtung
	$lo_options['direction'] = $lo_set["SortDir"];
	// filter angeben?
	if( count($lo_tmparr_cms) > 0 )
	{	
		// option erzeugen
		$lo_options['artspecs'] = $lo_tmparr_cms;
	}
	// artikel abfragen
	$lo_artlist = new ArticleCollection($lo_options);


	//----------------------------------------------------------------
	// falls artikel vorliegen
	if ($lo_artlist->count > 0) 
	{
		//----------------------------------------------------------------
		// pruefe ob vorhanden artikelanzahl groesser ist als 
		// max angezeigt werden sollen
		if( $lo_set["MaxArt"] < $lo_artlist->count ) 
		{	$lo_limitart = $lo_set["MaxArt"];	} 
		else 
		{	$lo_limitart = $lo_artlist->count;	}

		//--------------------------------------------
		// page seiten und offset erstellen
		while( true )
		{
			// falls offset erreicht wurde, abbrechen
			if( $lo_limit >= $lo_limitart )
			{
				// damit array wenigsten 0 werte enthaelt
				if( count($lo_pagearr) == 0 )
				{	$lo_pagearr[1] = 0;}
				break;
			}
			// neue seite mit zugehoerigen offset einfuegen
			$lo_pagearr[$lo_seite] = $lo_limit;
			// offset errechnen
			$lo_limit += $lo_set["LimitArt"];
			// seitenzahl erhoehen
			$lo_seite += 1;
		}

		//----------------------------------------------------------------
		// pruefe ob var 'page' in den moeglichen seitenangaben existiert
		if( array_key_exists($lo_page, $lo_pagearr) )
		{}
		else 
		{	$lo_page = 1;	}


		//----------------------------------------------------------------
		// durchlaufe alle gefundenen artikel
		for( $i = 0; $i < $lo_limitart; $i++ ) 
		{
			// hole naechsten artikel
			$lo_article = $lo_artlist->nextArticle();
//echo $lo_page.'<pre>';print_r($lo_article);echo '</pre>';

			//----------------------------------------------------------------
			// zeige artikel an, wenn er innerhalb der zu zeigenden page liegt
			if( ($i >= $lo_pagearr[$lo_page]) && ($i <($lo_pagearr[$lo_page]+$lo_set["LimitArt"])) )
			{
				$lo_articleid = $lo_article->getField('idart');
	
				$lo_tplimg = '';

				//----------------------------------------------------------------
				// falls bild angezeigt werden soll
				if( $lo_set["ShowImg"] == 'true' ) 
				{
					// hole artikelinhalt
					$text_html = $lo_article->getContent('CMS_HTML', 1);
	
					// suche nach bildern
					$regEx = "/<img[^>]*?>.*?/i";
					$match = array ();
					preg_match($regEx, $text_html, $match);
	
					// suche nach bildquelle und splite pfad auf
					$regEx = "/(src)(=)(['"]?)([^"']*)(['"]?)/i";
					$img = array ();
					preg_match($regEx, $match[0], $img);
					$img_src = preg_split("/\//", $img[0]);
	
					// finde dateinanem ohne endung
					$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]);
	
					$lo_imgname = $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;
							$lo_imgname = preg_replace("/$suffix/", "", $img_name);
							$lo_imgname = $lo_imgname.".[a-zA-Z]{3}";
						}
					}
	
					$lo_teaserimghref = '';
	
					//----------------------------------------------------------------
					// bild vorhanden ist vorhanden
					if( strlen($lo_imgname) > 0 ) 
					{
						$sql = 'SELECT * FROM '.$cfg["tab"]["upl"].' WHERE filename REGEXP \''.$lo_imgname.'\'';
						$db->query($sql);

						// bild info abfragen	
						if ($db->next_record()) 
						{
							$lo_filename = $db->f('filename');
							$lo_dirname = $db->f('dirname');
						}

						// dateipfad zusammensetzen
						$img_path = $cfgClient[$client]["upl"]["path"].$lo_dirname.$lo_filename;
						// href des bildes erzeugen
						$lo_teaserimghref = capiImgScale($img_path, $lo_set["ImgWidth"], $lo_set["ImgHeight"], $crop = false, $expand = false, $cacheTime = 1000, $wantHQ = false);

					} // end if strlen
	
					//----------------------------------------------------------------
					// falls href des bildes gefunden
					if (strlen($lo_teaserimghref) > 0) 
					{	$lo_tplimg = '<img src="'.$lo_teaserimghref.'" alt="'.$lo_imgname.'">';	} 
					else 
					{	$lo_tplimg = '';	}
	
				} // end if noimg 		
	
				// html-tags entfernen
				$lo_tplheadline = strip_tags($lo_article->getContent('CMS_HTMLHEAD', 1));
				$lo_tplheadline = str_replace($replace, " ", $lo_tplheadline);
	
	
				$lo_tplhref = $sess->url('front_content.php?idcat='.$lo_set["IdCat"].'&idart='.$lo_articleid);
				$lo_tpltext = trim($lo_article->getField('summary'));

				//----------------------------------------------------------------
				// falls feld zusammenfassung leer ist, content holen
				if (strlen($lo_tpltext) == 0) 
				{
					// content holen
					$lo_tpltext = trim( $lo_article->getContent('CMS_HTML', 1) );
					// <br> in ' ' umwandeln
					$lo_tpltext = strtr($lo_tpltext, $lo_transarr);
					// alle html-tags entfernen
					$lo_tpltext = trim( strip_tags($lo_tpltext) );
					// wenn text laenger als gewuenscht ist
					if( strlen($lo_tpltext) > $lo_set["MaxCharContent"] )
					{
						// wenn text angezeigt werden soll
						if( (int)$lo_set["MaxCharContent"] > 0 )
						{
							$lo_tpltext  = capiStrTrimAfterWord($lo_tpltext, (int)$lo_set["MaxCharContent"]);
							$lo_tpltext .= '...';
						}
						else 
						{	$lo_tpltext = '';	}
					}
				}		
				
		
				//----------------------------------------------------------------
				// wenn sortierungsoption zeitwert ist, dann formatieren
				if( ($lo_set["SortBy"] == 'created') || ($lo_set["SortBy"] == 'lastmodified') || ($lo_set["SortBy"] == 'published') )
				{	$lo_tpl->set('d', 'SORTVALUE', strftime($lo_set["SortValueFormat"], strtotime($lo_article->getField($lo_set["SortBy"]))) );	}
				else
				{	$lo_tpl->set('d', 'SORTVALUE', $lo_article->getField($lo_set["SortBy"]) );	}
				// andere templatevars
				$lo_tpl->set('d', 'HEADLINE', $lo_tplheadline);
				$lo_tpl->set('d', 'TEXT', $lo_tpltext);
				$lo_tpl->set('d', 'HREF', $lo_tplhref);
				$lo_tpl->set('d', 'IMG', $lo_tplimg);
	
				$lo_tpl->next();
	
			} // end for
		}
		
		//----------------------------------------------------------------
		// pagelinks erstellen
		foreach( $lo_pagearr as $lo_key => $lo_value) 
		{
			$lo_href = $sess->url('front_content.php?idcat='.$lo_set["IdCat"].'&page='.$lo_key);
			if( $lo_page == $lo_key )
			{	$lo_pagelnk .= '<strong>'.$lo_key.'</strong>&nbsp;&nbsp;';	}
			else
			{	$lo_pagelnk .= '<a href="'.$lo_href.'">'.$lo_key.'</a>&nbsp;&nbsp;';	}
		}

		$lo_tpl->set('s', 'PAGE', $lo_pagelnk);
		$lo_tpl->generate('templates/'.$lo_set["Template"]);

	}
	//----------------------------------------------------------------
	// keine artikel vorhanden
	else 
	{
		$lo_tpl->generate('templates/'.$lo_set["TemplateNoArt"]);
	}
}?>

ippkem
Beiträge: 10
Registriert: Do 21. Dez 2006, 22:04
Kontaktdaten:

Beitrag von ippkem » Do 29. Mär 2007, 12:10

Danke für die prompte Anpassung! Funktioniert!

Zeilenumbrüche werden nicht nur durch <br> sondern auch durch <p> erzeugt. Lässt sich dies auch berücksichtigen?

Grüße
Ippkem

maveric2001
Beiträge: 112
Registriert: Mi 21. Jun 2006, 07:00
Wohnort: Nordhausen
Kontaktdaten:

Beitrag von maveric2001 » Do 29. Mär 2007, 14:13

klar kannste selber machen. einfach die zeile

Code: Alles auswählen

$lo_transarr = array ('<br>' => ' ', '<BR>' => ' ','<br/>' => ' ','<br />' => ' ','<BR/>' => ' ', '<BR />' => ' ');
anpassen, ala

Code: Alles auswählen

$lo_transarr = array ('<br>' => ' ', '<BR>' => ' ','<br/>' => ' ','<br />' => ' ','<BR/>' => ' ', '<BR />' => ' ', '<p>' => ' ', '</p>' => ' ');

ippkem
Beiträge: 10
Registriert: Do 21. Dez 2006, 22:04
Kontaktdaten:

Beitrag von ippkem » Do 29. Mär 2007, 14:47

Ja, super!

:D

Dank und Gruß!
Ippkem

laurin

Beitrag von laurin » Fr 30. Mär 2007, 17:45

Hey, das Script funktioniert bis auf eine Sache perfekt:

Und zwar wird der Titel nicht in {Headline} widergegeben - er wird also garnicht angezeit. Was tun?

Edit: Ich vermute, dass bei Headline eigentlich das ausgegeben werde müsste, was man als Seitentitel eingegeben hat. Oder irre ich?

laurin

Beitrag von laurin » Sa 31. Mär 2007, 17:11

Ich habe noch ein kleines Problem: Ich will einige ältere Artikel (z.b. aus dem Jahr 2004) einbinden. Ich habe deshalb in der Datenbank das creation-Datum angepasst, doch auch wenn ich nach "published" oder "add-Date" sortiere, zeigt er mir immer das Datum an, an dem ich es tatsächlich ins Contenido eingefügt hab. Ich will den aber zurückdatieren.

Hat jemand eine Idee?

maveric2001
Beiträge: 112
Registriert: Mi 21. Jun 2006, 07:00
Wohnort: Nordhausen
Kontaktdaten:

Beitrag von maveric2001 » Mo 2. Apr 2007, 12:22

laurin hat geschrieben:Hey, das Script funktioniert bis auf eine Sache perfekt:

Und zwar wird der Titel nicht in {Headline} widergegeben - er wird also garnicht angezeit. Was tun?

Edit: Ich vermute, dass bei Headline eigentlich das ausgegeben werde müsste, was man als Seitentitel eingegeben hat. Oder irre ich?
{HEADLINIE} = titel des artikels oder besser die headlinie des artikels oder noch besser 'CMS_HTMLHEAD' des artikels
{TITEL} = der konfigurierte wert 'headlinie'

maveric2001
Beiträge: 112
Registriert: Mi 21. Jun 2006, 07:00
Wohnort: Nordhausen
Kontaktdaten:

Beitrag von maveric2001 » Mo 2. Apr 2007, 12:25

laurin hat geschrieben:Ich habe noch ein kleines Problem: Ich will einige ältere Artikel (z.b. aus dem Jahr 2004) einbinden. Ich habe deshalb in der Datenbank das creation-Datum angepasst, doch auch wenn ich nach "published" oder "add-Date" sortiere, zeigt er mir immer das Datum an, an dem ich es tatsächlich ins Contenido eingefügt hab. Ich will den aber zurückdatieren.

Hat jemand eine Idee?
kommt drauf an welches 'creation-Datum' du geaendert hast. du muss es in der tabelle 'con_art_lang'....bin jetzt adhoc aber nicht sicher

laurin

Beitrag von laurin » Mo 2. Apr 2007, 12:59

Das mit dem Datum hat jetzt geklappt, Danke!
maveric2001 hat geschrieben:
{HEADLINIE} = titel des artikels oder besser die headlinie des artikels oder noch besser 'CMS_HTMLHEAD' des artikels
{TITEL} = der konfigurierte wert 'headlinie'
Das hat leider noch nicht geklappt. Ich will dass bei {HEADLINIE} das erscheint, was ich unter Eigenschaften, Seitentitel eingebe (das ist das, was als <title>TITEL</title> ausgegeben wird.

Ein bisschen verwirrt bin ich auch deswegen: Mal ist im Code headline, mal headlinie - ist das Absicht?

maveric2001
Beiträge: 112
Registriert: Mi 21. Jun 2006, 07:00
Wohnort: Nordhausen
Kontaktdaten:

Beitrag von maveric2001 » Mo 2. Apr 2007, 13:08

laurin hat geschrieben: Das hat leider noch nicht geklappt. Ich will dass bei {HEADLINIE} das erscheint, was ich unter Eigenschaften, Seitentitel eingebe (das ist das, was als <title>TITEL</title> ausgegeben wird.
ist so nicht geplant, muesste ich erst umbauen. wenn dann wuerde er aber eeh nur den Seitentitel des artikels ausgeben, der das modul benutzt.
laurin hat geschrieben: Ein bisschen verwirrt bin ich auch deswegen: Mal ist im Code headline, mal headlinie - ist das Absicht?
nöö

laurin

Beitrag von laurin » Mo 2. Apr 2007, 17:11

Wo kann ich denn das eingeben, was als HEadline erscheint?

maveric2001
Beiträge: 112
Registriert: Mi 21. Jun 2006, 07:00
Wohnort: Nordhausen
Kontaktdaten:

Beitrag von maveric2001 » Mi 4. Apr 2007, 09:30

laurin hat geschrieben:Wo kann ich denn das eingeben, was als HEadline erscheint?
im endeffekt brauchst du den {HEADLINIE} auch nicht. du kannst genau so gut dein template so anpassen wie du es brauchst!

Gesperrt