Wrap Artikelliste/detail

Dieser RT legt einen Umschließer (Wrapper) um eine Artikelliste oder Artikeldetailliste.

Dazu werden im jeweiligen Template zwei neue Tags benötigt <!--ARTICLEX_ENTRY//--> und <!--ARTICLEX_END//-->.

Eingebaute Alternative (seit V1.3.3 2007-05-18): Wrapper für Artikellisten -und Detaildarstellung:



rt_article_list_wrap V1.0 2010/02/23

Docu:
Forum: wrap article summary list template
Autor: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.3
Version: V1.0

Tag: <!--ARTICLEX_ENTRY//--> und <!--ARTICLEX_END//-->

Dateiname: rt_article_list_wrap.php

Ort: template/inc_script/frontend_render/

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

  • $phpwcms['allow_ext_render'] = 1;



Template:

TAG im Artikel-Listen/Detail-Template:

<!--ARTICLEX_ENTRY//-->
.....
..... 
 article list template
.....
..... 
<!--ARTICLEX_END//-->


Der vom System erzeugte Quelltext sieht nun so aus:

<!-- ARTICLEX_ENTRY//-->
....
<!-- ARTICLEX_END//-->
....
<!-- ARTICLEX_ENTRY//-->
....
<!-- ARTICLEX_END//-->
 
<!-- ARTICLEX_ENTRY//-->
....
<!-- ARTICLEX_END//-->


Nach dem Scriptdurchlauf:

<div class="whow">
....
<!-- ARTICLEX_END//-->
....
<!-- ARTICLEX_ENTRY//-->
....
<!-- ARTICLEX_END//-->
 
<!-- ARTICLEX_ENTRY//-->
....
</div>

Das erste <!--ARTICLEX_ENTRY//--> wird durch die Anweisung in $_prefix im Script ersetzt.

Das letzte <!--ARTICLEX_END//--> wird durch die Anweisung in $_suffix im Script ersetzt.


PHP:

In den beiden Variablen $_prefix und $_suffix werden die umschließenden Anweisungen eingetragen.

  $_prefix  = '<div class="whow">';   // before articles-list
  $_suffix  = '</div>';               // behind articles-list


Datei: template/inc_script/frontend_render/rt_article_list_wrap.php

rt_article_list_wrap

<?php
/**
 *******************************************************************
 *
 * 23.02.2010 Wrap an article list
 * V1.0 K.Heerrmann http://planmatrix.de
 *
 * TAG in Article list template:
 * ----------------------------------
 * <!--ARTICLEX_ENTRY//-->
 *
 * article list template
 *
 * <!--ARTICLEX_END//-->
 * ----------------------------------
 *
 * Filename: rt_article_list_wrapper.php
 * Folder:  /template/inc_script/frontend_render/
 * Switch:  $phpwcms['allow_ext_render'] = 1; (/config/phpwcms/conf.inc.php)
 *
 * Forum:   http://forum.phpwcms.org/viewtopic.php?p=110038#p110038
 *******************************************************************/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ----------------------------------------------------------------
 
 
// Article list wrapper
// ================================================================
 
// Is there the right article list?
if( ! (strpos($content["all"],'<!--ARTICLEX_ENTRY//-->') === false)) {
 
    // -----CUSTOM------------------------------------
 
    $_prefix     = '<div class="whow">';        // before articles-list
    $_suffix     = '</div>';                    // behind articles-list
    $_a_entry    = '<!--ARTICLEX_ENTRY//-->';
    $_a_end      = '<!--ARTICLEX_END//-->';
 
    // -----------------------------------------------
 
    // reverting for faster replace
    $_a_end     = strrev($_a_end);
    $_suffix    = strrev($_suffix);
 
    // make a regex like pattern
    $_a_entry    = preg_quote($_a_entry, '/');
    $_a_end      = preg_quote($_a_end, '/');
 
 
    // Only the first entry
    // ----------------------------------
    $content["all"] = preg_replace('/'.$_a_entry.'/',$_prefix.LF,$content["all"],1);
 
    // Only the last entry (reverting is much faster as REGEX (last))
    // ----------------------------------
    $content["all"] = strrev($content["all"]);
    $content["all"] = preg_replace('/'.$_a_end.'/',$_suffix.LF,$content["all"],1);
    $content["all"] = strrev($content["all"]);
 
}
 
?>
deutsch/ersetzer_rts/frontend_render/wrap-article-list.txt · Last modified: 2018/06/03 18:09 (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