ich würde gerne eine Artikelnavigation bauen, mit der man endlos durch die artikel der aktuellen Kategorie blättern kann und den Startartikel überspringt. Ich versuche mal darzustellen wie es im Moment funktioniert und wie es sein sollte.
Ist zustand:
First article
previous article (startarticle) – next article
Article in between
previous article – next article
Last article
nothing (gibt gar nichts aus)
_____
So sollte es sein:
First project
previous article (last project) – next article
Article in between
previous article – next article
Last Article
previous article – next article (first project)
Habe schon einiges ausprobiert, komm aber leider nicht mehr weiter und würde mich super freuen wenn jemand eine Idee hätte. Das Ausgangsmodul habe ich hier gefunden http://usysto.net/blog/redaxo_artikel_blaettern.php, jedoch ein wenig umgebaut und aufgeräumt.
Danke,
Stefan
Code: Alles auswählen
<?php
$categoryId = $this->getValue('category_id');
$articleId = $this->getValue('article_id');
// all articles from current category
$articles = OOArticle::getArticlesOfCategory($categoryId, true);
// reverse articles
$reversedArticles = array_reverse($articles);
// vars
$number = 0;
$curNumber = 0;
$arrArt = array();
$output = '';
// all online articles from this category
foreach ($reversedArticles as $article) {
if (is_object($article)) {
// count
$number++;
// current article
if ($article->getId() == $articleId) {
$curNumber = $number;
$prev_number = $number + 1;
$next_number = $number - 1;
}
// new array with all articles
$arrArt[$number] = $article;
}
}
$nextName = $arrArt[$next_number]->getName();
$prevName = $arrArt[$prev_number]->getName();
$nextUrl = rex_getUrl($arrArt[$next_number]->getId());
$prevUrl = rex_getUrl($arrArt[$prev_number]->getId());
// if next article exists
if (is_object($arrArt[$next_number])) {
$nextart = ' <a href="'.$nextUrl.'">'.$nextName.'</a> ';
}
// if prev article exists
if (is_object($arrArt[$prev_number])) {
$prevart = ' <a href="'.$prevUrl.'">'.$prevName.'</a> ';
}
// if another article exists
if (isset($nextart) || isset($prevart)) {
$output = ''.$prevart.' '.$nextart.'';
}
echo $output;
?>