Teaser: Clear areas if no content available

If there is not Content for the teaser available, you can use this snippet to kill entries in the header and footer of the template from CP before delivery. Like that the output of the CP-title or the container avoided if no content is present.

In teaser template we have to insert additional tags.

Description:

- To identify this CP, it is important to place the entry <!--TEASERX_01//--> into the head area of the template, analogous to the entry in the script.

- If there is no content available, all messages between <!--TEASERX_LEER_01//--> and <!--TEASERX_LEER_02//--> are removed.

- Additionally you have to insert <!--TEASER_ENTRY_START//--> <!--TEASERX_CONTENT//--> <!--TEASER_ENTRY_END//-->.

<!--TEASERX_CONTENT//--> serves as a simple mark to determine whether content is present or not.


<!--TEASER_HEAD_START//-->    // ----- Built-in tag

<!--TEASERX_01//-->           // CP Identifier        (New tag)

<!--TEASERX_LEER_01//-->      // Delete range start   (New tag)

<div>
<h3>{TITLE}</h3>
<h5>{SUBTITLE}</h5>

<!--TEASERX_LEER_02//-->      // Delete range ende    (New tag)

<!--TEASER_HEAD_END//-->      // ----- Built-in tag



<!--TEASER_ENTRY_START//-->   // ----- Built-in tag

<!--TEASERX_CONTENT//-->      // If no content, it does not exist!!! (New tag)

<!--TEASER_ENTRY_END//-->     // ----- Built-in tag


<!--TEASER_FOOTER_START//-->  // ----- Built-in tag

<!--TEASERX_LEER_01//-->      // Delete range start   (New tag)
</div>
<!--TEASERX_LEER_02//-->      // Delete range ende    (New tag)

<!--TEASER_FOOTER_END//-->    // ----- Built-in tag



Docu: –
Forum: –

Author: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.4x
Version: V1.0 (22.02.2010)
Condition:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_init'] = 1;


Example template:

File: /template/inc_cntpart/teaser/my_template01.tmpl

my_template01.tmpl

<!--TEASER_HEAD_START//-->
<!--TEASERX_01//-->
<!--TEASERX_LEER_01//-->
<div style="margin:15px 0 15px 0;background-color:#E6E9F0;padding:7px;width:250px;">
 
<h3>{TITLE}</h3>
<h5>{SUBTITLE}</h5>
<br>
<!--TEASERX_LEER_02//-->
<!--TEASER_HEAD_END//-->
 
<!--TEASER_ENTRY_START//--><!--TEASERX_CONTENT//-->
    <div[PRIO] class="prio{PRIO}"[/PRIO]>
        <h3><a href="{ARTICLELINK}">{TITLE} &raquo;</a></h3>
        [IMAGE]<div style="float:left; margin:2px 5px 2px 0">{IMAGE}[CAPTION]<p>{CAPTION}</p>[/CAPTION]</div>[/IMAGE]
        <div>{DATE:d/m/y lang=EN}[SUBTITLE] <b>{SUBTITLE}.</b>[/SUBTITLE]
        {SUMMARY} <a href="{ARTICLELINK}">&raquo;</a></div>
    </div>[IMAGE]
    <!--
    Thumbnail {THUMB_NAME}
    Relative  {THUMB_REL}
    Absolute  {THUMB_ABS}
    WxH       {THUMB_WIDTH}px x {THUMB_HEIGHT}px
    //-->[/IMAGE]
<!--TEASER_ENTRY_END//-->
 
<!--TEASER_SPACER_START//-->
    <hr style="margin:7px 0 7px 0;padding:0;height:0;border:0;border-bottom:1px dotted #CCCCCC;clear:both" />
<!--TEASER_SPACER_END//-->
 
<!--TEASER_FOOTER_START//-->
<!--TEASERX_LEER_01//-->
    <div style="clear:both;height:1px"></div>
</div>
<!--TEASERX_LEER_02//-->
<!--TEASER_FOOTER_END//-->


PHP:

File: /template/inc_script/frontend_init/cp_trig_teaser01.php

cp_trig_teaser01.php

<?php
// -------------------------------------------------------------------------------------------
// obligate check for phpwcms constants
  if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");}
// -------------------------------------------------------------------------------------------
 
/**
 * *****************************************************************************
 * Titel aus Teaser loeschen wenn teaser keinen Inhalt
 * V1.0  22.02.10 K.Heermann  http://planmatrix.de
 *
 * ---- Template ------------------------------------------
 *
 * <!--TEASER_HEAD_START//-->    // ----- Eingebauter Tag
 *
 * <!--TEASERX_01//-->           // CP Identifizierer    (Neuer Tag)
 *
 * <!--TEASERX_LEER_01//-->      // Loeschbereich Anfang (Neuer Tag)
 *
 * <div>
 * <h3>{TITLE}</h3>
 * <h5>{SUBTITLE}</h5>
 *
 * <!--TEASERX_LEER_02//-->      // Loeschbereich Ende (Neuer Tag)
 *
 * <!--TEASER_HEAD_END//-->      // ----- Eingebauter Tag
 *
 *
 *
 * <!--TEASER_ENTRY_START//-->   // ----- Eingebauter Tag
 *
 * <!--TEASER_CONTENTX//-->      // Wenn kein Content, dann nicht vorhanden!!! (Neuer Tag)
 *
 * <!--TEASER_ENTRY_END//-->     // ----- Eingebauter Tag
 *
 *
 * <!--TEASER_FOOTER_START//-->  // ----- Eingebauter Tag
 *
 * <!--TEASERX_LEER_01//-->      // Loeschbereich Anfang  (Neuer Tag)
 * </div>
 * <!--TEASERX_LEER_02//-->      // Loeschbereich Ende    (Neuer Tag)
 *
 * <!--TEASER_FOOTER_END//-->    // ----- Eingebauter Tag
 *
 * *****************************************************************************
*/
 
 
function CP_TEASERX_01($text, & $data) {
 
    if( $data['acontent_type'] == 8 AND strpos($text, '<!--TEASERX_01//-->') ) {
 
        if (strpos($text, '<!--TEASERX_CONTENT//-->') == false) {
            $text = preg_replace('/<!--TEASERX_LEER_01\/\/-->(.*?)<!--TEASERX_LEER_02\/\/-->/ism', '<!--nix vorhanden//-->', $text);  // Head loeschen
        }
        // dumpVar($text);
    }
 
    return $text;
 
} // ---- END function
 
register_cp_trigger('CP_TEASERX_01');
 
?>
english/phpwcms_replacer_rts/frontend_init/cp_trigger/teaser-without-title-if-no-content.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