Custom replacements allow you to automatically replacement strings within a page with a different string. They are similar to custom variables except that:
- They don't need to be explicitly added to a page or view to be displayed
- They only work on pages (will not be parsed at the view level)
Creating Custom Replacements
- Open the "wiki/config/custom_replacements.php" file.
- Within the array, create a new entry whereby the key is the string that will be matched on the page, and the value is what it will be replaced with.
- As with many other features in the program, everything is language based, so when creating replacements, place them with the correct language array.
Assume I wanted to automatically parse a page for my name and replace it with a link to my Twitter page. I could add the following to the
array( 'en' => array( 'jbelelieu' => '<a href="http://twitter.com/jbelelieu" target="_blank">@jbelelieu</a>', ), );
Now whenever I place the string "jbelelieu" on a page:
# My Sample Page Hello, I created Banana Dance Lite and my name is jbelelieu.
The program will automatically replace "jbelelieu" with the link to my Twitter:
<h1>My Sample Page</h1> <p>Hello, I created Banana Dance Lite and my name is <a href="http://twitter.com/jbelelieu" target="_blank">@jbelelieu</a>.</p>
Last modified 2 years ago.