Strict Standards: Declaration of action_plugin_dlcount::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/dlcount/action.php on line 14

Strict Standards: Declaration of action_plugin_indexmenu::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/indexmenu/action.php on line 169

Strict Standards: Declaration of action_plugin_ipban::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/ipban/action.php on line 67

Strict Standards: Declaration of action_plugin_loglog::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/loglog/action.php on line 82

Strict Standards: Declaration of action_plugin_navi::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/navi/action.php on line 46

Strict Standards: Declaration of action_plugin_uparrow::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/uparrow/action.php on line 69

Strict Standards: Declaration of action_plugin_userspagecreate::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /home/www/wiki/lib/plugins/userspagecreate/action.php on line 97

Strict Standards: Declaration of cache_instructions::retrieveCache() should be compatible with cache::retrieveCache($clean = true) in /home/www/wiki/inc/cache.php on line 289

Warning: Cannot modify header information - headers already sent by (output started at /home/www/wiki/lib/plugins/dlcount/action.php:14) in /home/www/wiki/inc/auth.php on line 312

Strict Standards: Only variables should be passed by reference in /home/www/wiki/doku.php on line 71

Warning: Cannot modify header information - headers already sent by (output started at /home/www/wiki/lib/plugins/dlcount/action.php:14) in /home/www/wiki/inc/actions.php on line 154
Article menu (+counter +archive) [phpwcms-HowTo:wiki]

Strict Standards: Declaration of syntax_plugin_code::render() should be compatible with DokuWiki_Syntax_Plugin::render($format, &$renderer, $data) in /home/www/wiki/lib/plugins/code/syntax.php on line 41

Strict Standards: Declaration of syntax_plugin_tip::render() should be compatible with DokuWiki_Syntax_Plugin::render($format, &$renderer, $data) in /home/www/wiki/lib/plugins/tip/syntax.php on line 38

Article menu (+counter +archive)

(Simple version)

RT like the CP Article menu, enhanced to show archived articles too and two counter: 1) Article hidden, 2) number of articles which can be displayed.

rt_article_menu_archive V1.0 23.03.09
rt_article_menu_archive V1.1 05.09.09

Update: 16.08.09 KH: + counter for “How many of the first articles are to be hidden” (0 = nothing hidden)
Update: 05.09.09 KH: + counter for “How many articles are to be shown” (0 = all)
Update: 10.12.09 KH: + BBCode in titel and subtitel possible

Syntax: {ARTICLE_MENU_ARCHIVE:category-ID, count-hide} (Both parameters must be set)
Syntax: {ARTICLE_MENU_ARCHIVE:category-ID, count-hide, count-article} (All three parameters must be set)

E.g.:{ARTICLE_MENU_ARCHIVE:-1,0,0} Actual category, none of the first articles is hidden , dipslay all articles
E.g.:{ARTICLE_MENU_ARCHIVE:23,2,5} Article in category 23(ID), the first two articles are hidden, displays the the first five articles if avaialbel

Docu: –
Forum: –

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

Based on the cp article menu.

Tag: {ARTICLE_MENU_ARCHIVE:category-ID, count-hide, count-article} or {ARTICLE_MENU_ARCHIVE:-1, count-hide, count-article} for the actual category

Filename: rt_article_menu_archive.php

Location: template/inc_script/frontend_render/

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

  • $phpwcms['allow_ext_render'] = 1;


article menu archive

<?php
/*************************************************************************************
   Copyright notice
 
   (c) 2002-2008 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
 
   This script is part of PHPWCMS. The PHPWCMS web content management system is
   free software; you can redistribute it and/or modify it under the terms of
   the GNU General Public License as published by the Free Software Foundation;
   either version 2 of the License, or (at your option) any later version.
 
   The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
   A copy is found in the textfile GPL.txt and important notices to the license
   from the author is found in LICENSE.txt distributed with these scripts.
 
   This script is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
   PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
   This copyright notice MUST APPEAR in all copies of the script!
 
-------------------------------------------------------------------------------------
15.03.09 KH (flip-flop) CP article menu cut out (frontend snippet)
   Enhanced for showing archived articles
   {ARTICLE_MENU_ARCHIVE:category-ID}
   If you use the automatic for category-ID, please set category-ID = -1 (the current category is selected)
   E.g.:{ARTICLE_MENU_ARCHIVE:-1}
 
16.08.09 KH Update: + counter for "How many of the first articles are to be hidden"
   {ARTICLE_MENU_ARCHIVE:category-ID, count-hide}
   E.g.:{ARTICLE_MENU_ARCHIVE:-1,0}  (Both parameters must be set)
 
05.09.09 KH Update: + count_article for "How many of articles are to be shown" (if available)
   {ARTICLE_MENU_ARCHIVE:category-ID, count-hide, count-articles}
   E.g.:{ARTICLE_MENU_ARCHIVE:-1,0,4}  (All three parameters must be set)
         Automatic category-ID, no article hidden, show the first for articles
 
10.12.09 KH Update: + BBCode in titel and subtitel possible
   E.g.: [i]Title[/i]  [b]Subtitle[/b] ......
*************************************************************************************/
 
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ----------------------------------------------------------------
 
 
//article menu enhanced
// $catid: the category ID where the articles are (-1 = current category))
// $leading_article_hide: How many of the first articles are to be hidden
// $count_article: How many articles are to be shown (0=all)
 
function my_article_menu_archive ($catid = 0, $leading_article_hide = 0, $count_article, $CNT_TMP = '') {
 
 
 // Test if all paramters have integer format
if (!(is_intval($catid) AND is_intval($leading_article_hide) AND is_intval($count_article)) ) {
    echo '============================================ <br>';
    echo '&nbsp;<b>ERROR</b>: Wrong integer parameter in {ARTICLE_MENU_ARCHIVE:...<br>';
    echo '============================================ <br>';
    return false;
}
 
 
global $aktion;
 
 
// ===== Simulated CP paramter ================================================
 
// 0: all articles
// 1: article_archive_status=1 AND article_begin<NOW() AND article_end<NOW()
// 2: article_archive_status=1 AND article_begin<NOW() AND article_end>NOW()
// 3: article_archive_status=1 AND article_begin>NOW() AND article_end>NOW()
 
// 4: article_archive_status=0 AND article_begin<NOW() AND article_end<NOW()
// 5: article_archive_status=0 AND article_begin<NOW() AND article_end>NOW()
// 6: article_archive_status=0 AND article_begin>NOW() AND article_end>NOW()
 
$article_archive_status       = 2;  // Show entries with activated archive status?
 
 
// How many of the first articles are to be hidden (hardcoded) ----------------------
 
// $leading_article_hide         = 1;  // default: 0 (now article hide)
 
 
// CSS classes and IDs ----------------------
 
$alinkmenu['wrap_all']        = array('<div class="vlist">','</div>');    // Wrap around all
$alinkmenu['wrap_data']       = array('','');                             // Data wrap begin, end
$alinkmenu['wrap_title']      = array('','');                             // Title wrap around all  begin, end
$alinkmenu['wrap_subtitle']   = array('','');                             // SubTitle wrap begin, end
$alinkmenu['wrap_summary']    = array('','');                             // Wrap around summary  begin, end
$alinkmenu['class_active_link'] = 'active_link';                          // Active link class
 
 
$alinkmenu["style_before"] = '';  // Format before every data set.
$alinkmenu["style_behind"] = '';  // Format behind every data set.
 
 
/*
// CSS classes and IDs ----------------------
 
$alinkmenu['wrap_all']        = array('<div class="teaser_right">','</div>');                   // Wrap around all
$alinkmenu['wrap_data']       = array('','');                                                   // Data wrap begin, end
$alinkmenu['wrap_title']      = array('<div style="padding-bottom:2px; "><h6>','</h6></div>');  // Title wrap around all  begin, end
$alinkmenu['wrap_subtitle']   = array('<p style="font-size: 0.8em;  ">','</p>');                // SubTitle wrap begin, end
$alinkmenu['wrap_summary']    = array('','');  // Wrap around summary  begin, end
$alinkmenu['class_active_link'] = 'active_link';                                                // Active link class
 
 
 
$alinkmenu["style_before"] = '';  // Format before every data set.
// Format behind every data set.
$alinkmenu["style_behind"] = '<div style="margin:5px 0 8px 0;padding:0;height:1px;border:0;border-bottom:1px dotted #CCCCCC;clear:both"><!-- line //--></div>';
*/
 
// Insert title/subtitle name and css for the virtual content part
$virt_article_title      = '';    // <div id="box02_top_header"><h1>MyTitle</h1></div>
$virt_article_subtitle   = '';    // <div id="box02_top_header"><h2>MySubTitle</h2></div>
 
 
$alinkmenu['subtitle_on']   = 0;            // Article sub title text output [0|1]
 
// Content part parameters ------------------
$alinkmenu['headertext']    = 0;            // summary text [0|1]
$alinkmenu['ul']            = 2;            // 1: render as unordered list / 2: render as div /  3: render as table
$alinkmenu['class']         = '';           // wrapped class
$alinkmenu['maxchar']       = 0;            // maxchars summary
$alinkmenu['morelink']      = ' &raquo;';   // more link text
$alinkmenu['hideactive']    = 0;            // hide active article in article menu
 
 
 
/* Sorting order for "second entry"
------------------------------
 $ao[2] = ' article_sort ASC';
 $ao[2] = ' article_sort DESC';
 $ao[2] = ' article_created ASC';
 $ao[2] = ' article_created DESC';
 $ao[2] = ' article_tstamp ASC';
 $ao[2] = ' article_tstamp DESC';
 $ao[2] = ' article_begin ASC';
 $ao[2] = ' article_begin DESC';
 $ao[2] = ' article_title ASC';
 $ao[2] = ' article_title DESC';
 $ao[2] = ' article_end ASC';
 $ao[2] = ' article_end DESC';
 
 $ao[2] = ' article_priorize DESC,'.$ao[2];
 ------------------------------ */
 
// Sorting order ----------------------------
 $ao['2']  = ' article_priorize DESC,'; // Don´t change
 $ao['2'] .= ' article_sort ASC';       // second entry
 
 
// ===== END defination =======================================================
 
// catid = -1: The current category is selected
$alinkmenu["catid"]         = ($catid < 0) ? $GLOBALS['content']['cat_id'] : $catid; // Article category-ID
$alinkmenu['link']          = '';     // reserved, don´t change
 
 
switch($article_archive_status) {
  case 0:   // article_archive_status ist not set
    $alinkmenu['article_archive_status'] = ' ';
    break;
  case 1:
    $alinkmenu['article_archive_status'] = 'AND article_archive_status=1 AND article_begin<NOW() AND article_end<NOW() ';
    break;
 
  case 2:
    $alinkmenu['article_archive_status'] = 'AND article_archive_status=1 AND article_begin<NOW() AND article_end>NOW() ';
    break;
 
  case 3:
    $alinkmenu['article_archive_status'] = 'AND article_archive_status=1 AND article_begin>NOW() AND article_end>NOW() ';
    break;
 
  case 4:
    $alinkmenu['article_archive_status'] = 'AND article_archive_status=0 AND article_begin<NOW() AND article_end<NOW() ';
    break;
 
  case 5:
    $alinkmenu['article_archive_status'] = 'AND article_archive_status=0 AND article_begin<NOW() AND article_end>NOW() ';
    break;
 
  case 6:
    $alinkmenu['article_archive_status'] = 'AND article_archive_status=0 AND article_begin>NOW() AND article_end>NOW() ';
    break;
 
  default:
    $alinkmenu['article_archive_status'] = 'AND article_archive_status=1 AND article_begin<NOW() AND article_end<NOW() ';
}
 
 
$alink_sql  = "SELECT article_id, article_title ,article_subtitle, article_cid, article_summary ";
$alink_sql .= "FROM ".DB_PREPEND."phpwcms_article ";
$alink_sql .= "WHERE article_public=1 AND article_aktiv=1 AND article_deleted=0 ";
$alink_sql .= 'AND article_cid='.intval($alinkmenu["catid"]).' ';
$alink_sql .= $alinkmenu['article_archive_status'];
 
if(!empty($alinkmenu['hideactive'])) {
 
  $alink_sql .= 'AND article_id != '. $aktion[1] . ' ';
}
$alink_sql .= 'ORDER BY ' . $ao[2] ;
 
 
$result = _dbQuery($alink_sql);
 
 
 if(isset($result[$leading_article_hide]['article_id'])) {
 
  $count     = 0;
  // Max article output ( Input <= 0   --> All articles output )
  ($count_article <= 0) ? $count_art == -1000 : $count_art = 0;
 
  foreach($result as $value) {
 
   if( $count >= $leading_article_hide ) {  // Hide first articles?
 
    if( $count_article > $count_art ) {  // Max article shown
 
 
      $tempRowSpan      = '';
 
     $value['article_summary'] = preg_replace('/<br[^>]*?>$/i', '', $value['article_summary']);  // article_summary
 
 
      if($alinkmenu['headertext'] && !empty($value['article_summary'])) {
 
        $alinkmenu['sum'] = $value['article_summary'];
 
 
        if(!empty($alinkmenu['maxchar'])) {
 
          $alinkmenu['sum']     = clean_replacement_tags($alinkmenu['sum']);
          $alinkmenu['sum']     = remove_unsecure_rptags($alinkmenu['sum']);
          $alinkmenu['sum']     = preg_replace('/\s/i', ' ', $alinkmenu['sum']);
          $alinkmenu['sum']     = preg_replace('/\s{2,}/i', ' ', $alinkmenu['sum']);
          $alinkmenu['sum']     = trim(decode_entities($alinkmenu['sum']));
          $alinkmenu['sum']   = wordwrap($alinkmenu['sum'], $alinkmenu['maxchar'], "\n");
          list($alinkmenu['sum']) = explode("\n", $alinkmenu['sum']);
          $alinkmenu['sum']   = trim($alinkmenu['sum']);
          $alinkmenu['sum']   = html_specialchars($alinkmenu['sum']);
 
          if(!empty($alinkmenu['morelink'])) {
 
            $alinkmenu['sum']  .= '<a href="index.php?aid='.$value['article_id'].'">';
            $alinkmenu['sum']  .= $alinkmenu['morelink'];
            $alinkmenu['sum']  .= '</a>';
 
          }
          // Set css wrapper
         $alinkmenu['sum'] = LF.$alinkmenu['wrap_summary'][0].LF.$alinkmenu['sum'].LF.$alinkmenu['wrap_summary'][1];
 
        }
 
      } else {
 
 
 
        $alinkmenu['sum'] = false;
 
      }
 
     // SubTitle ----------------------
      $alinkmenu['subtitle'] = (!empty($value['article_subtitle']) AND !empty($alinkmenu['subtitle_on'])) ?
      $alinkmenu['wrap_subtitle'][0].render_bbcode_basics(html_specialchars($value['article_subtitle'])).$alinkmenu['wrap_subtitle'][1] : '';
 
     // Format before every data set.
      $alinkmenu['link'] .= LF.$alinkmenu["style_before"].LF;
 
 
      // set link or link with active link class --------------------
 
      $alinkmenu['link_wrap'] = '<a href="index.php?aid='.$value['article_id'].'">';
 
      if (empty($alinkmenu['hideactive']) AND ($value['article_id'] == $aktion[1])) {
          $alinkmenu['link_wrap'] = '<a href="index.php?aid='.$value['article_id'].'" '.get_class_attrib($alinkmenu['class_active_link']).'>';
     }
 
 
 
      switch($alinkmenu['ul']) {
 
       case 1:   // render as unordered list
            $alinkmenu['link'] .= '<li>'.$alinkmenu['wrap_data'][0].$alinkmenu['wrap_title'][0];
//            $alinkmenu['link'] .= '<a href="index.php?aid='.$value['article_id'].'">';
            $alinkmenu['link'] .= $alinkmenu['link_wrap'];
            $alinkmenu['link'] .= render_bbcode_basics(html_specialchars($value['article_title']));
            $alinkmenu['link'] .= $alinkmenu['morelink'].'</a>'.$alinkmenu['wrap_title'][1];
            $alinkmenu['link'] .= $alinkmenu['subtitle'];
 
            if($alinkmenu['sum'] !== false) {
              $alinkmenu['link'] .= "\n".$alinkmenu['sum'];
            }
 
            $alinkmenu['link'] .= $alinkmenu['wrap_data'][1]."</li>\n";
            break;
 
        case 2:   // render as div
            $alinkmenu['link'] .= '<div>'.$alinkmenu['wrap_data'][0].$alinkmenu['wrap_title'][0];
//            $alinkmenu['link'] .= '<a href="index.php?aid='.$value['article_id'].'">';
            $alinkmenu['link'] .= $alinkmenu['link_wrap'];
            $alinkmenu['link'] .= render_bbcode_basics(html_specialchars($value['article_title']));
            $alinkmenu['link'] .= $alinkmenu['morelink'].'</a>'.$alinkmenu['wrap_title'][1];
            $alinkmenu['link'] .= $alinkmenu['subtitle'];
 
            if($alinkmenu['sum'] !== false) {
              $alinkmenu['link'] .= "\n".$alinkmenu['sum'];
            }
 
            $alinkmenu['link'] .= $alinkmenu['wrap_data'][1]."</div>\n";
            break;
 
        default:  // render as table
 
            // SubTitle ------------
            if ($alinkmenu['subtitle'] !== ''  AND !empty($alinkmenu['subtitle_on'])) {
              $tempRowSpan    = ' rowspan="2"';
              $alinkmenu['subtitle'] = "<tr>\n\t<td>" .$alinkmenu['subtitle']. "</td>\n</tr>\n";
            }
 
            if($alinkmenu['sum'] !== false) {
              $tempRowSpan    = ' rowspan="2"';
              $alinkmenu['sum'] = "<tr>\n\t<td>" . $alinkmenu['sum'] . "</td>\n</tr>\n";
            }
 
            $alinkmenu['link'] .= "<tr>\n\t<td valign=\"top\"".$tempRowSpan." nowrap=\"nowrap\">".$template_default["article"]["link_article_sign"]."</td>\n\t";
//            $alinkmenu['link'] .= '<td>'.$alinkmenu['wrap_title'][0].'<a href="index.php?aid='.$value['article_id'].'" ';
            $alinkmenu['link'] .= '<td>'.$alinkmenu['wrap_title'][0].$alinkmenu['link_wrap'];
//            $alinkmenu['link'] .= get_class_attrib($template_default["article"]["link_article_class"]).">";
            $alinkmenu['link'] .= render_bbcode_basics(html_specialchars($value['article_title'])).$alinkmenu['morelink'].'</a>'.$alinkmenu['wrap_title'][1]."</td>\n</tr>\n";
            $alinkmenu['link'] .= $alinkmenu['subtitle'];
            $alinkmenu['link'] .= $alinkmenu['sum'];
 
      }
 
      // Format behind every data set.
     $alinkmenu['link'] .= $alinkmenu["style_behind"];
 
     } // END if $count_art ....
     $count_art++;
 
   } // END if $count ....
 
   $count++;
 
  } // END foreach
 
//  mysql_free_result($result);
 
}
 
if($alinkmenu['link']) {
 
  switch($alinkmenu['ul']) {
 
      case 1:   // render as unordered list
            $alinkmenu['link'] = "<ul>\n" . $alinkmenu['link'] . "</ul>\n";
            break;
 
      case 2:   // render as div
            break;
 
      default:  // render as table
            $alinkmenu['link'] = '<table border="0" cellspacing="0" cellpadding="0">'."\n" . $alinkmenu['link'] . "</table>\n";
 
  }
 
  // now check if class name is given
  // if so wrap article menu in div
  if(!empty($alinkmenu['class'])) {
 
    $alinkmenu['link'] = '<div class="' . html_specialchars($alinkmenu['class']) . "\">\n" . $alinkmenu['link'] . "</div>\n";
 
  }
  $CNT_TMP .= $alinkmenu['wrap_all'][0].LF.$virt_article_title . $virt_article_subtitle . $alinkmenu['link'].LF.$alinkmenu['wrap_all'][1].LF;
 
}
 
unset($alinkmenu);
 
return $CNT_TMP;
}
 
// $content['all'] = str_replace('{ARTICLE_MENU_ARCHIVE}', my_article_menu_archive() ,$content['all']);
 
$content["all"] = preg_replace('/{ARTICLE_MENU_ARCHIVE:(.*?),(.*?),(.*?)}/e', 'my_article_menu_archive("$1","$2","$3")', $content["all"]);
 
?>
english/phpwcms_replacer_rts/frontend_render/article-menu-archive/article-menu-archive-count.txt · Last modified: 2009/12/10 11:10 by Knut Heermann (flip-flop)
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

Strict Standards: Only variables should be passed by reference in /home/www/wiki/doku.php on line 79