REPLACEMENT TAG: Repository

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

REPLACEMENT TAG: Repository

Post by pSouper »

This thread is a repository for custom replacement tags written by anyone.

FOR USERS
  • in order to keep this thread as clean and efficient as possile plesae do not post ANY posts within this thread INCLUDING expresions of thanks & congrats, how to's & how do I's etc.
  • all bug reports should go as a pm to theauthor of the replacement tag's post so that they may fix it
  • ensure you have a custom replacement tag file within your 'phpwcms_template/inc_script/frontend_render/' directory. if you do not (thier is not one by defualt) then create one using the tutorial in the
    following post.
  • abuse of these rules will result in the post being relocated or deleted so as to maintain the efficientcy of this thread
FOR CONTRIBUTORS...
Please only post your tag once and follow the followinf rules...
  • One post per tag
  • All edits, bug fixes, additions and substractions should be maintained within the original post - comment as required.
  • Maintain comments for author, revision,descprition,usage and example
  • All replacement tags should have a unique name (please check against new RT's within this thread)
  • All custom functions should have a unique name (please check against new RT's within this thread)
  • SEARCH & REPLACE Pairs should have the array unmber replaced with an 'x' so as to force the end user to allocate a unique number to thier own custom replacement tag file - enableing then to pick and choose witch tags they like.
Replacement Tags will all include a SEARCH array and REPLACE array pair, each will have an 'x' within square braces, e.g SEARCH[x]

Tags that are posted will require the 'x' to be replaced with a unique number that does not appear in any other custom replacement tag within the custom replacement tag file.

USAGE: Once you have the basic custom replacement tag file you may pick and choose the tags you wish to use by following the following steps...
  • Cut & Paste the code snippet from any post and place in the indicated part of the custom replacement tag file. This will either be in the FUNCTIONS or the TAGS section.
  • replace the 'x' within SEARCH[x] & REPLACE[x] to a unique number that idealy follows on from the last tags number: for example the next tag after SEARCH[1] & REPLACE[1] should be SEARCH[2] & REPLACE[2]
  • please note that each tag with have a search/replace pair that must use the same unique number identifyer.
I hope this thread will be helpful to many.
Last edited by pSouper on Mon 1. May 2006, 15:07, edited 3 times in total.
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

CREATING your custom replacement tag file

Post by pSouper »

copy & save the following code to a new file within 'phpwcms_template/inc_script/frontend_render/customtags.php'

Code: Select all

<?
// parse the $string and replace all possible instances of the following {RT}'s

// CUSTOM FUNCTIONS REQUIRED GO BETWEEN HERE...

// ...AND HERE

// REPLACEMENT TAG PARSER FUNCTION
function customTagParser($string) { 
	
	//SEARCH AND REPLACE ITEMS GO BETWEEN HERE...

	//...AND HERE

        $string = preg_replace($search, $replace, $string);
	$string = str_replace('\'', ''', $string);
	$string = str_replace('&quot;', '"', $string);
   return $string;   // spit out the final webpage for display
}
 //parse the whole webpage $content["all"] is the fully rendered webpage your site displays
$content["all"] = (customTagParser ($content["all"]));
?>
Last edited by pSouper on Mon 1. May 2006, 14:52, edited 2 times in total.
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

format for replacement tag submission...

Post by pSouper »

Code: Select all

//Tag Name:
//Author:
//Version:
//Description:
//Requirements:
//Usage:
//Example:
$search[x]    = '';
$replace[x]	= '';
Last edited by pSouper on Mon 1. May 2006, 14:50, edited 1 time in total.
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Insert linebreak with a given height

Post by pSouper »

Code: Select all

// TagName: LINEBREAK
// Author: pSouper
// Version:1.0
//Description: Inserts a customaisable linebreak of a given height anywhere in an article/content part
// Requirements: none
// Usage: {LINESBREAK:space height}
//Example: {LINEBREAK:10}
$search[x]		= '/\{LINEBREAK:(.*?)\}/';
	$replace[x]	= '<div style="margin: 0pt 0pt $1px; padding: 0pt; clear: both;"></div>';
Last edited by pSouper on Mon 1. May 2006, 14:58, edited 1 time in total.
trip
Posts: 657
Joined: Tue 17. Feb 2004, 09:56
Location: Cape Town, South Africa
Contact:

Post by trip »

http://phpwcms.raramuri.com/

Try this for a growing list
If you have noticed the reptags, you will see we are trying to bring in a standard... but it really depends on the DEVELOPER!!!

TriP
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

JUMPCP: jump to any article & content part

Post by pSouper »

to be used ONLY with this hack

Code: Select all

//Tag name: JumpCP
//Author: pSouper
//Version:1.0
//Description: provides a link to an article & content part with the option to set the _target
//Requirements: none
//Usage for aliased categories: {JUMPCP:article alias,content part ID,link name,html target type}
//Example: {JUMPCP:id=homepage,44,open article 'homepage' & contentpart 44 in a new page,_SELF}
//Usage for non-aliased categories: {JUMPCP:id=article ID,content part ID,link name,html target type}
// Example: {JUMPCP:id=10,44,open article 10 & contentpart 44 in a new page,_BLANK}
	
	$search[x]		= '/\{JUMPCP:(.*?),(.*?),(.*?),(.*?)\}/';
	$replace[x]	= '<a href="index.php?$1#$2" target="$4">$3</a>';
Post Reply