{{indexmenu_n>710}}
====== 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.
A navigation for terminated articles in archive are available: [[english/phpwcms_replacer_rts/frontend_render/article-menu-archive]]
**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 \\
**27.12.09 KH**
$content['list_mode'] == true
changed to
$content['struct'][$content['cat_id']]['acat_topcount'] > 1
Tag: -- \\
Fileiname: **rt_article_move_to_archive.php**
Folder: ** template/inc_script/frontend_render/ **
**Condition:** -> [[http://www.phpwcms-docu.de/conf_inc_php_en.phtml|/config/phpwcms/conf.inc.php]] \\
* ##$phpwcms['allow_ext_render'] = 1;##
----
----
1
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) {
// Update 27.12.09 KH:
// Nur ausfuehren wenn in der Kategorie "Anzahl an Top-Artikeln:" > 1 und die angegebene Kategorie aktiv ist
// Only run if in category "top article count:" > 1 and the specified category is active
if( ($content['struct'][$content['cat_id']]['acat_topcount'] > 1) && ($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 archives, please donate or write wiki articles or translate some.** \\
\\
..... The IDs of the source categories //(where the article list is)// please register in the array **$my_article_cat_id['source']**.
The Target- or archive categories //(where the articles at expiration to be kept)// please register in **$my_article_cat_id['archive']**.
These are registered as pairs into the two arrays, every source category with one target category.
$my_article_cat_id['source'] = array( 4, 71, 90, 230) article-listing-categories
| | | |
$my_article_cat_id['archive'] = array(70, 72, 95, 150) article-archive-categories
..... An assignable number of years can be add and stored to the end-date, in order to be able to navigate in archives with the built-in function article menu. The number of years should be added registered into the variable **$boost_year**. \\
E.g. ##$boost_year = '10';## //(for +10 years: 2009-05-07 20:34:00 --> 2019-05-07 20:34:00) ....//