Their uses are many and when used correctly they can be very powerful. A common use for replacement variables is to correct annoying spelling mistakes. For example, on the vBulletin Community Forums a replacement variable exists to replace all instances of the incorrect abbreviation for vBulletin VBB with the correct abbreviation vB.
Another use for replacement variables is to insert commonly-used blocks of HTML. For example, a replacement variable could be set up to replace <tablestart> with <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">.
Therefore, your templates could have blocks of code like this:
<tablestart> <tr> <td class="alt1">Cell contents...</td> </tr> </table>
<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center"> <tr> <td class="alt1">Cell contents...</td> </tr> </table>
The replacement variable system is activated in the last stages of page processing before the HTML is delivered to a visitor's browser. The system searches for target text in the completed, parsed templates. In some ways this can be very useful, but there are caveats of which you should be aware.
Warning:
While powerful, replacement variables can also break the functionality of your board if used incorrectly.
For example, creating a replacement variable to search for 'html' and replace it with 'HTML', any hyperlinks pointing to files with a .html suffix will have those links replaced with .HTML, which is not the same file as far as Unix web servers are concerned.
Worse still, you might choose to use a replacement variable to turn every instance of the word home into a hyperlink pointing to your home page: <a href="home.html">home</a>.
While this will work, you will have the situation where the word 'home' is used in locations where creating a hyperlink would cause invalid HTML, such as this:
For example, creating a replacement variable to search for 'html' and replace it with 'HTML', any hyperlinks pointing to files with a .html suffix will have those links replaced with .HTML, which is not the same file as far as Unix web servers are concerned.
Worse still, you might choose to use a replacement variable to turn every instance of the word home into a hyperlink pointing to your home page: <a href="home.html">home</a>.
While this will work, you will have the situation where the word 'home' is used in locations where creating a hyperlink would cause invalid HTML, such as this:
<img src="home.gif" alt="" />...which would end up being delivered to the browser as
<img src="<a href="home.html">home</a>.gif" alt="" />...which is obviously invalid HTML and will not function correctly.