Halli Hallo,
ich hab grad mit olien noch ein wenig geplaudert und ergebniss war nun folgende Modifikation des obigen Moduls:
- Code: Alles auswählen
<?php
if (!$REX[GG])
{
// Im Backend nichts machen
return;
}
$start = !empty($_GET['start']) ? (int) $_GET['start'] : 0; // Startitem
$offset = 3; // 3 Items pro Seite
$cats = array( 3, 1); // alle Kategorien die Du "indizieren" willst
$articles = array();
foreach ( $cats as $catId) {
$cat = OOCategory::getCategoryById( $catId);
// CatIds die nicht funktionieren aussortieren
if( $cat === null) {
continue;
}
$cat_articles = $cat->getArticles( true);
foreach ( $cat_articles as $ooarticle) {
// keine Startartikel anzeigen
if ( $ooarticle->isStartPage()) {
continue;
}
// Damit keine Endlosschleife passiert, den Artikel der die Pagination setzt überspringen
if ( $ooarticle->getId() == REX_ARTICLE_ID) {
continue;
}
$articles[] = $ooarticle;
}
}
$articles_length = count( $articles);
// Sortieren nach Erstellungsdatum
if ( $articles_length > 0) {
usort( $articles, "sortArticlesByCreateDate");
}
$article_list = array_slice( $articles, $start, $offset);
foreach ( $article_list as $ooarticle) {
$artId = $ooarticle->getId();
$article = new article();
$article->setArticleId( $artId);
echo $article->getArticle();
}
$prevStart = $start - $offset;
if ( $prevStart < 0)
{
$prevStart = '';
}
$nextStart = $start + $offset;
if ( $nextStart >= $articles_length)
{
$nextStart = '';
}
$link_format = '<a href="index.php?article_id=REX_ARTICLE_ID&start=%s">%s</a>';
// Vorherige Seite Link
if ( $prevStart !== '') {
echo sprintf( $link_format, $prevStart, 'vorherige Seite');
}
// Nächste Seite
if ( $nextStart !== '') {
echo sprintf( $link_format, $nextStart, 'nächste Seite');
}
// Sortierfunktion
function sortArticlesByCreateDate( $artA, $artB) {
$yearA = (int) substr( $artA->_erstelldatum, 0, 4);
$monthA = (int) substr( $artA->_erstelldatum, 4, 2);
$dayA = (int) substr( $artA->_erstelldatum, 6, 2);
$yearB = (int) substr( $artB->_erstelldatum, 0, 4);
$monthB = (int) substr( $artB->_erstelldatum, 4, 2);
$dayB = (int) substr( $artB->_erstelldatum, 6, 2);
$createA = mktime( 0, 0, 0, $monthA, $dayA, $yearA);
$createB = mktime( 0, 0, 0, $monthB, $dayB, $yearB);
if ( $createA == $createB) {
return 0;
}
return $createA > $createB ? -1 : 1;
}
?>
- Alle Artikel werden nach erstellungsdatum sortiert ausgegeben (neuste immer oben)
- Es werden keine Startartikel ausgegeben
- per "
$cats = array( 3, 1); // alle Kategorien die Du "indizieren" willst" kann man konfigurieren welche Kategorien alle einbezogen werden sollen
Das ganze im Einsatz seht Ihr auf
http://kreischer.de/
Gruß,
Markus