CP´s text w/image, images, images <div>/special

Using this rt we can be taken the information from file center into each ALT tag of the cp´s “image with text”, “images”, “images <div>” or “images special”.


Result frontend:

with text from the filecenter field [keywords: additional]:

<td class="imagelisttd">
  <a target="_blank" title="CAPTION01" rel="lightbox[NyIEy]" href="content/images/e4b330854785567800c45d6b1150eae2.jpg">
  <img height="100" border="0" width="150" title="TITILE01" alt="Keywords: image Expo" class="imagelistimg" src="content/images/d695aa3cffb893d7502079e11d739b53.jpg"></a>
</td>

Description:

Example: CP images

- In caption may not be entered a alt-tag, so that RT can work properly.

CAPTION-TEXT|||TITLE-TEXT

- In notes field we must fill in the tag ”[XIMAGES_INFO]” in order to indicate clearly that this CP is treated accordingly.


Script:

- In the script we can specify in “CUSTOM var” which info from the file center is inserted into the alt-tag.

$replace_alt    = 'f_shortinfo';  // default = 'f_shortinfo'
  'Entry'          -> input field in file center
 +--------------+--------------------------------------+
  'f_shortinfo'    ->  keywords: additional: 
  'f_longinfo'     ->  long info:
  'f_copyright'    ->  copyright: 
  'f_tags'         ->  tags:  
 +--------------+--------------------------------------+



Docu: –
Forum: –

Author: K.Heermann (flip-flop) http://planmatrix.de
CMS Version: >= 1.4x
Version: V1.0 (05.05.2010)

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

  • $phpwcms['allow_ext_init'] = 1;


PHP:

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

cp_trig_image_read_filecenter10.php

<?php
// -------------------------------------------------------------------------------------------
// obligate check for phpwcms constants
    if (!defined('PHPWCMS_ROOT')) {
        die("You Cannot Access This Script Directly, Have a Nice Day."); }
// -------------------------------------------------------------------------------------------
/**
 *********************************************************************************************
 * Simple Version 1.0
 * 05.05.10 K.Heermann  http://planmatrix.de
 *
 * Bilder-Infos aus Dateizentrale in alt-Tag der CP-Bilder einsetzen (CP Bilder/<div>/spezial)
 * In der Bildunterzeile: Bildunterzeile|||Titel
 * Tag im CP Notizfeld:   [XIMAGES_INFO] -> Nur zur Identifikation "Ist das der richtige CP"
 
 * Using image infos from file center in alt tag of the images in cp image/<div>/special
 * Tag in CP notes field: [XIMAGES_INFO] -> Only for identification "is this the right CP"
 * In CP in caption: Caption-Text|||Title-Text
 *
 **********************************************************************************************
*/
 
 
function TRIGG_CP_IMAGE_READ_FILECENTER_V10($text, & $data) {
 
    // Der richtige CP: Text/wImage /1) / images (2) / image <div> (29) / image special (31)
    // and Tag available?
 
    if  (   $data['acontent_type'] ==  1 OR  // cp image/text
            $data['acontent_type'] ==  2 OR  // cp images
            $data['acontent_type'] == 29 OR  // cp image <div>
            $data['acontent_type'] == 31 AND // cp image special
            (strpos($data['acontent_comment'], '[XIMAGES_INFO]') !== false) // TAG is set ?  // TAG vorhanden?
        )
 
    {
 
    // ===CUSTOM var ========================================================
 
    // Put in the right string ------
    $replace_alt    = 'f_shortinfo';  // default = 'f_shortinfo'
 
 
    // 'DB feld'        -> Eingabefeld in der Dateizentrale
    // 'DB field'       -> input field in file center
    // +--------------+----------------------------------------------------+
    // 'f_shortinfo'    -> keywords: additional: // Keywords: Zusätzlich:
    // 'f_longinfo'     -> long info:            // Info:
    // 'f_copyright'    -> copyright:            // Copyright
    // 'f_tags'         -> tags:                 // Tag/Schlagwort:
    // +--------------+----------------------------------------------------+
 
    // ===END CUSTOM var ====================================================
 
 
        // alle file IDs holen wenn vorhanden direkt aus dem serialiserten String //    i:0;s:2:"22";
        // catch all file IDs if available from the serialized string
 
        if ($data['acontent_type'] == 1) {      // cp image/text
            preg_match_all('/^(\d*?):/',$data['acontent_image'], $fileID);
 
        } else                                  // all other image cp´s
            preg_match_all('/i:0;s:2:"(.*?)";/',$data['acontent_form'], $fileID);
 
 
        // Irgendetwas verwertbares vorhanden?
        // Is there any content available?
 
        if (!empty ($fileID[0])) {
 
            // Read the file entries from database
            // -----------------------------------
 
            $ids = join("','", $fileID[1]);
 
            $sql  = 'SELECT * ';
            $sql .= 'FROM '.DB_PREPEND.'phpwcms_file ';
            $sql .= "WHERE f_id IN ('$ids')";
 
            $db_data  = _dbQuery($sql);
            // -----------------------------------
 
            // Inhalt aus DB verfuegbar?
            // Is there any content from db available?
 
            if(isset($db_data[0])) {
 
                $search =  '';
                $replace = '';
 
                // Daten  holen und ersetzen
                // Catch data from db and replace in text
 
                foreach($fileID[1] as $key=>$value0) {
 
                    foreach($db_data as $key1=>$value1)
                        if ($value1['f_id'] == $value0) {
                            $search   =  $value1['f_name'];
                            $replace = $value1[$replace_alt];
                            break;
                        }
 
                    // Replace in alt tag: file name to text from file center
                    $text = preg_replace('/alt="'.$search.'"/i', 'alt="'.$replace.'"', $text, 1);
 
 
                } // ----- END foreach
 
            } // ------ END isset($db_data[0]
        }
    }
 
    return $text;
}
 
register_cp_trigger('TRIGG_CP_IMAGE_READ_FILECENTER_V10');
 
?>


english/phpwcms_replacer_rts/frontend_init/cp_trigger/filecenter-text-in-image-cps/all-image-cps.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