NP_Macros

General Plugin info
Author: Anand
Current Version: 0.3
Download: np_macros_v0.3.zip
Code: macroscode and MacrosAdmin
Demo: -
Forum Thread: here

Really brief documentation :

Installing

  • Copy, paste and save this code in your plugins directory as NP_Macros.php.
  • Create a directory inside your plugin directory called macros.
  • Copy, paste and save this code in the newly created directory as index.php.

How to use the plugin

Go to your plugins page and click on the admin page against the Macros plugin. Alternatively, you will see that at the bottom of the new quick menu you will see the plugin admin URL listed.

This plugin doesn't update the database like the earlier macro plugin. Instead, just before an item is displayed, the plugin modifies it to show the changed text.

Construct proper well formed regular expressions. Remember, any macros you create will be applied to every item. Any mistake you make in a macro will result in every item being displayed wrongly. But since no database updates are made, you are safe from any data corruption.

Read the ereg and preg function pages on php.net on how to create proper regular expressions.

Tips and Tricks

For all simple patterns, use Ereg pattern. Although slower, it is much easier to create a ereg pattern than a preg.

Every preg pattern has to be encapsulated like this, if anand is your pattern, then it should be /anand/

You should not escape your preg replace strings.

Example Simple Regular Expression

Pattern String: ilsv
Replace String: I like silly videos

Every time you write ilsv in your item it will be replaced with I like silly videos.

Example Perl Style Reg Expression

Preg Pattern to replace text links to proper href links,

Pattern 	/(?<!<a href=\")((http|ftp)+(s)?:\/\/[^<>\s]+)/i 
Replace String 	<a href="\0">\0</a>

Plugin review

NP_Macros version 0.3 works with Nucleus CMS version 3.31 - 2007-11-15 kg

macros.txt · Last modified: 2007/11/15 20:51 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki