Jump to anchor

This RT offers the possibility to jump to CP-anchors and anchors itself set within an article.

FIXME Better translate

Prerequisites:

  • Autom. anchor of each CP given with Achor [x] e.g. <a name="cpid123"> (123 would be the id of the CP)
  • Anchor that can be placed anywhere in the CP using the TAG {A:MeinAnker} (<a name="MeinAnker">).


TAG: * {GO-A:CP-ID,Link text} * {GO-A:Ankertext,Link text}


Condition in the TAG:

  • CP-ID:
    • Numeric value (It is automatic. assumed that a contentpart-id part is meant).
  • Anchor_name:
    • One word, no spaces, no special characters or umlauts (It is assumed that a valid anchor is set in the page).
  • Link text:
    • Minimum word length is three characters

If a condition is not fulfilled, an error text displayed in the FE.

<note> The RT does not check for the existence of valid jump targets! </note>

Example:

{GO-A:149,Link text}

<a href="#cpid149" class="phpwcmsAnchorLink-GO" title="Link text">Link text</a>


{GO-A:MyAnchorName,Link text}

<a href="#MyAnchorName" class="phpwcmsAnchorLink-GO" title="Link text">Link text</a>



rt_goto_anchor V1.0 16.08.2011

Docu: –
Forum: http://forum.phpwcms.org/viewtopic.php?p=131995

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

Tag: – {GO-A:CP-ID, Link text} oder {GO-A:Anchor_text, Link text}

Filename: rt_goto_anchor.php

Folder: template/inc_script/frontend_render/

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

  • $phpwcms['allow_ext_render'] = 1;



Code:

File: template/inc_script/frontend_render/rt_goto_anchor.php

rt_goto_anchor

<?php
/**
 * *****************************************************************************
 * 16.08.2011 V1.0 K.Heermann http://planmatrix.de
 *
 * GoTo anchor link
 *
 * Tags v1.0:
 * - {GO-A:CP-ID,Link text}
 * - {GO-A:Anchor_name,Link text}
 *
 *CP-ID:
 * - Only numeric values
 *
 * Anchor_name:
 * - One word, no spaces
 * - No special characters and umlauts.
 *
 * Link text:
 * - If there is no link text an error occures
 * - Minimum word length is three characters
 * *****************************************************************************
*/
// -----------------------------------------------------------------------------
// obligate check for phpwcms constants
    if (!defined('PHPWCMS_ROOT')) {
        die("You Cannot Access This Script Directly, Have a Nice Day."); }
// -----------------------------------------------------------------------------
 
 
if (strpos($content["all"],'{GO-A:') !== false) {  // Is there any anchor jump?
 
    // cp anchor is available
    IF (strpos($content["all"],'<a name="cpid') !== false) {
 
        $mySearch     = '/\{GO-A:(\d+),([\x20-\x7F]{3,})\}/is';
        $myReplace     = '<a href="#cpid$1" class="phpwcmsAnchorLink-GO" title="$2">$2</a>';
 
        $content['all'] = preg_replace($mySearch, $myReplace, $content['all']);
    }
 
    // TAG anchor is available
    IF (strpos($content["all"],'class="phpwcmsAnchorLink"') !== false) {
 
        $mySearch     = '/\{GO-A:([^\x7B-\xFF\s\W]+?),([\x20-\x7F]{3,})\}/is';
        $myReplace     = '<a href="#$1" class="phpwcmsAnchorLink-GO" title="$2">$2</a>';
        $content['all'] = preg_replace($mySearch, $myReplace, $content['all']);
    }
 
    // Error output
    $mySearch     = '/\{GO-A:(.*?)\}/is';
    $myReplace     = '<b style="color:red">Anchor error:</b> "$1"';
    $content['all'] = preg_replace($mySearch, $myReplace, $content['all']);
 
    $content['all'] = str_replace('&#92;&#039;', '&#039;', $content['all']);
    $content['all'] = str_replace('&amp;quot;', '&quot;', $content['all']);
}
 
?>
english/phpwcms_replacer_rts/frontend_render/anchor-jump.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