This is an old revision of the document!


Article move into archive

Autom. move of expired article into a archive category

This script is working for one article list in one category and one archive category.

The ID of the source category (where the article list is) please register in $my_article_cat . The Target- or archive category (where the articles at expiration to be kept) please register in $my_archive_cat .

If the switch [x] archives is set in category and a visitor accesses the category where the article list is, the expired article is still indicated. At the same time it was shifted into archives. The script is only running if a user visits this category.

If you don´t like this behavior, please open the switch [ ] Archive in category. Thus the script runtime increases a little, since the database must be addressed immediately. With small sides (number of articles < 300) that is uncritical.

Condition: * Source category must be run in article list-mode: Site structure - categoriy –> top article count > 1

  • Articles in this category: edit article basis information –> [x](available after end date (archive))


Recommended:

  • Source category = archive [x] (faster processing)
  • Target category = archive [x]



rt_article_move_to_archive V1.0 26.07.09

Docu: –
Forum: –

Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS version: >= 1.3.x
Version: V1.0

Tag: –

Fileiname: rt_article_move_to_archive.php

Folder: template/inc_script/frontend_render/

Condition:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_render'] = 1;


rt_article_move_to_archive

<?php
/* *****************************************************************************
 Autom. Verschieben von abgelaufenen Artikeln in eine Archivkategorie
 autom. move of expired article into a archive category
 
 26.07.09 V1.0 Knut Heermann (flip-flop) http://planmatrix.de
 
 Bedingung // Condition:
 - Quell-Kategorie muss im Artikel-Listenmodus arbeiten "Anzahl an Top-Artikeln > 1"
 - // Source category must be run in article list-mode "top article count > 1"
 - Artikel in dieser Kategorie "[x](verfuegbar nach Enddatum (archivieren))"
 - // Articles in this category "[x](available after end date (archive))"
 
 
 Empfohlen // Recommended:
 Quellkategorie // Source category = Archiv [x]  (Schnellere Abarbeitung // faster processing)
 Zielkategorie  // Target category = Archiv [x]
 
***************************************************************************** */
 
// -----------------------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); }
// -----------------------------------------------------------------------------
 
 
// USERINPUT ======================================================
 
// Kategorie-ID in der das Artikel-Listing laeuft   (Quelle)
// Category-ID where the article listing is running (source)
$my_article_cat = 4;
 
// ID der Archiv-Kategorie in die verschoben werden soll (Ziel)
// ID of the archive category (target)
$my_archive_cat = 70;
 
// USERINPUT END ==================================================
 
 
 
// Nur ausfuehren wenn der Listenmodus in der Kategorie eingeschaltet und die angegebene Kategorie aktiv ist
// Only run if list mode in category is true and the specified category is active
if( $content['list_mode'] == true && $content['cat_id'] == $my_article_cat) {
 
    $article = array();
 
    // Kategorie-Schalter [x] Archive gesetzt? (fuer schnellere Abarbeitung)
    // Category switch [x] archive set?        (for faster prcessing)
 
    if ( $content['struct'][$content['cat_id']]['acat_archive'] == 1 ) {
 
       $my_time = time(); // for faster processing
 
 
    // Gibt es einen Artikel bei dem das Datum abgelaufen ist?
    // Is there an article with expired date?
 
       foreach($content['articles'] as $key => $value) {
 
         if ($content['articles'][$key]['article_killdate'] < $my_time ) {
            $article[] = $value['article_id'];
         }
       }
 
      // Kategorie-Schalter [ ] Archive offen ? - etwas langsamere Verarbeitung
      // Category switch [x] archive unset?  - slow down prcessing a little bit
    } else
      {
        $article[0] = 0;  // Fuer Aktivierung sql-Update // for activating sql-update
      }
 
 
   // Wenn mindestens ein Artikel vorhanden ist
   // If minimum one article exists
   if(count($article)) {
 
    $sql  = 'UPDATE '.DB_PREPEND.'phpwcms_article SET ';
    $sql .= "article_cid= ".$my_archive_cat." ";
    $sql .= "WHERE article_cid= ".$my_article_cat." AND article_archive_status=1 AND article_deleted=0 ";
    $sql .= " AND article_public=1 AND article_aktiv=1 AND article_end < NOW() ";
 
    $queryResult = _dbQuery($sql, 'UPDATE');
 
   }
}
 
?>


If you liked to have the version for several categories and archive, please donate or write wiki articles or translate some.

english/phpwcms_replacer_rts/frontend_render/article-move-into-archive.1248754214.txt.gz · Last modified: 2018/06/03 18:08 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0