Modul 'In jedem Artikel der Artikelliste navigieren'

Gesperrt
homtata
Beiträge: 1145
Registriert: Mi 14. Jan 2004, 14:41
Kontaktdaten:

Modul 'In jedem Artikel der Artikelliste navigieren'

Beitrag von homtata »

Hallo,

ich brauchte ein Modul, mit dem ich innerhalb der Artikel einer Newsliste vor und zurück navigieren kann. Also: Artikel aus der Liste aufrufen, und dann soll unter dem Artikel eine "vor / zurück" sowie eine "Zurück zur Liste" Navigation erscheinen.
Ich habe das wie folgt gelöst - die Sortierung ist an das für die Liste eingesetzte Modul anzupassen im Template, und im Outputmodul ist der jeweilige Link zur Liste von Hand anzupassen, das ist aus Zeitgründen nicht in den Modul-Input integriert. Ausgelesen wird die aktuelle Kategorie, in der der Artikel sich befindet, daher wird diese nicht mehr separat über das Template konfiguriert.

Input:

Code: Alles auswählen

?><?php
/**
* $RCSfile$
*
* Description: Artikel Navigation / Ergänzung zum Modul "News"
*
* @version 1.0.0 by Viktor Lehmann <www.tone2tone.com>
* @based on modul "News" by Andreas Lindner
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2005-08-12, changed 2008-08-20
* }}
*
* $Id$
*/

#Select category


#Select sort field and sort order
$sortdate = 'checked';
$cms_imgsize = "CMS_VALUE[14]";
$cms_limit_articles = "CMS_VALUE[15]";
$cms_sort_direction = "CMS_VALUE[16]";
if ("CMS_VALUE[17]" != '') {
	$cms_include_start_article = ' checked';
} else {
	$cms_include_start_article = '';
}

if ("CMS_VALUE[3]" == 'sortdate') {
	$sortdate = 'checked';
	$sortnum = '';
	$sorttitle = '';
}
elseif ("CMS_VALUE[3]" == 'sortnum') {
	$sortdate = '';
	$sortnum = 'checked';
	$sorttitle = '';
}
elseif ("CMS_VALUE[3]" == 'sorttitle') {
	$sortdate = '';
	$sortnum = '';
	$sorttitle = 'checked';
}

echo '<table cellpadding="0" cellspacing="0" border="0">

        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung nach Datum").':</td>
          <td style="padding:5px;"><input type="radio" name="CMS_VAR[3]" value="sortdate" '.$sortdate.'></td>
        </tr>
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung nach Nummer").':</td>
          <td style="padding:5px;"><input type="radio" name="CMS_VAR[3]" value="sortnum" '.$sortnum.'></td>
        </tr>
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung nach Backendartikelname").':</td>
          <td style="padding:5px;"><input type="radio" name="CMS_VAR[3]" value="sorttitle" '.$sorttitle.'></td>
        </tr>
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung aufsteigend").':</td>
          <td style="padding:5px;">';
if (strtolower($cms_sort_direction) == 'desc') {
	echo '<input type="radio" name="CMS_VAR[16]" value="asc"/>';
} else {
	echo '<input type="radio" name="CMS_VAR[16]" value="asc" checked/>';
}
echo '</td>
        </tr>
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung absteigend").':</td>
          <td style="padding:5px;">';
if (strtolower($cms_sort_direction) == 'desc') {
	echo '<input type="radio" name="CMS_VAR[16]" value="desc" checked/>';
} else {
	echo '<input type="radio" name="CMS_VAR[16]" value="desc"/>';
}
echo '</td>
        </tr>';

$noimg = '';
if ("CMS_VALUE[13]" == 'true') {
	$noimg = 'checked';
}

#Include start article
echo '
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Startartikel in Liste einbeziehen").':</td>
          <td style="padding:5px;"><input type="checkbox" name="CMS_VAR[17]" value="yes"'.$cms_include_start_article.'></td>
        </tr>';

echo '</table>';
?><?php
Output:

Code: Alles auswählen

<?php
/**
* $RCSfile$
*
* Description: Artikel Navigation / Ergänzung zum Modul "News"
*
* @version 1.0.0 by Viktor Lehmann <www.tone2tone.com>
* @based on modul "News" by Andreas Lindner
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2005-08-12, changed 2008-08-20
* }}
*
* $Id$
*/

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

if (!isset($tpl) || !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
$template = "artikel_navigation.html";

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

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

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


	$options = array ('idcat' => $idcat, "start" => $with_start, "order" => $order, "direction" => $cms_sort_direction);

	$list = new ArticleCollection($options);

	$count = $list->count;

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

			$article = $list->nextArticle();
			$article_id = $article->getField('idart');
      $article_list[$i] = $article_id;
      
      if ( $article_id == $idart ) { $aktuell = $i; }
      	
      } // end for
      
      $article_next = $aktuell+1;

      if ( $article_next == $count ) { $article_next = 0; }
      $article_prev = $aktuell-1;
      if ( $article_prev < 0 ) { $article_prev = $count-1; }
      
			$href_next = $sess->url("front_content.php?idart=$article_list[$article_next]");
			$href_prev = $sess->url("front_content.php?idart=$article_list[$article_prev]");
			$href_cat  = $sess->url("front_content.php?idcat=50");

			$tpl->set('s', 'next', 'Nächster Artikel');
			$tpl->set('s', 'prev', 'Vorheriger Artikel');
			$tpl->set('s', 'cat',  'Zurück zur Übersicht');
			$tpl->set('s', 'href_next', $href_next);
			$tpl->set('s', 'href_prev', $href_prev);
			$tpl->set('s', 'href_cat',  $href_cat);

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



?>
dazu noch die artikel_navigation.html:

Code: Alles auswählen

<p><a href={href_prev} >{prev} </a> | <a href={href_next} >{next} </a> | <a href={href_cat} >{cat} </a> </p>
<br>
ravi
Beiträge: 54
Registriert: So 6. Aug 2006, 14:39
Kontaktdaten:

Re: Modul 'In jedem Artikel der Artikelliste navigieren'

Beitrag von ravi »

Hat sehr gut funktioniert.

Ich habe dies etwas anders verwendet indem ich die Navigation als Modul seperat gemacht habe:

- Newsnavigation dein neues Modul und Name für das html Template angepasst auf newsnavigation.html
- Eine Kategorie, welche die News enthält, diese bekommt ein Template: Titel, Subheader, Text, Newsnavigation
- Daneben ein Startartikel, welcher das normale Newsmodul von Contenido so verwendet, dass hier die Auflistung vorgenommen wird.
- Dieses html als Template in unter /cms/include/templates/newsnavigation.html

Code: Alles auswählen

<div class="artikelliste">
<br />
<p><a href={href_prev} >{prev} </a> | <a href={href_next} >{next} </a> | <a href={href_cat} >{cat} </a> </p>
<br />
</div>
Zuletzt geändert von ravi am Mi 3. Jun 2009, 17:57, insgesamt 1-mal geändert.
Gesperrt