Wiki:
Page name: Template Help [Logged in view] [RSS]
2011-06-20 18:06:48
Last author: Aradon Templar
Owner: Aradon Templar
# of watchers: 5
Fans: 0
D20: 17
Bookmark and Share

Template Help



<img:http://elftown.eu/stuff/2237_wiki_help_9y7vcgcflr5.jpg>

What is a template?


Templates are tools available to you when creating wikis. They allow you to take a shortcut by typing one thing and having it replaced by something else. For example, if you wanted to use that green divider image at the top of the page, but didn't want to type <img:http://elftown.eu/stuff/2237_wiki_help_9y7vcgcflr5.jpg> over and over again, you could use templates to let you type GREENDIVIDER and the wiki will automatically make the replacement for you. Templates don't always have to work with images, though. They can replace text with symbols, text with text, images with other images, etc. As long as in the wiki code you have some string of letters/numbers that you need replaced by other letters or numbers (which could include <img:> tags or wiki tags, etc), templates can create shortcuts for you.

<img:http://elftown.eu/stuff/Sheona_small_divider_00.jpg>

Okay well why do I need them?


You don't, really. Templates are just shortcuts for you, but some processes can become very simplified by using them. The best way to employ a template is probably to shortcut images, since the code for them gets pretty messy if you use a lot of them. Chesstemplate is probably the clearest use of templates I've seen. Since the owner wanted to create a visual chessboard, she created images for each piece on each color, so people could just replace the image urls to move pieces. You can imagine, though, that the code for that would be pretty hard to read. Thanks to templates, instead of 64 image tags, the codes were shrunk down to 2-3 letters, which made it very much easier to read. Other uses could be as filters. If you don't like profanity on your wiki, you could use a template to replace all curse words with symbols and censor your page. If you make the same typos a lot, you could use a template to replace 'yuo' with 'you' and 'alot' with 'a lot'. Or, you could come up with your own uses for templates. Use your imagination!

<img:http://elftown.eu/stuff/Sheona_small_divider_00.jpg>

Okay, neat! How do I use a template?


There are two parts to a template. First, you need a wiki that provides the template. This page tells any page that uses it what words to replace with what. On this wiki, all you need is to write a list of replacements. Each word to be replaced should be on its own line, followed by a colon (:), followed by the word to be replaced. For example, this template will replace a few of your typos with corrected versions:

yuo:you
cna:can
wnat:want

It's important to note that capitalization matters for these. 'Yuo' will not be replaced with anything. It is also important to remember that this string of letters anywhere will be replaced. If you make a template that makes the replacement 'and:also', then the word 'thousand' will suddenly become 'thousalso.' As a precaution against this, you might want to include spaces both before and after the words, to ensure that you are only replacing whole words. For example, this might be a better template, because you catch capitalization errors and this also skips words that don't appear by themselves (such as in parts of other words):

yuo : you
Yuo : You
cna : can
Cna : Can
wnat : want
Wnat : Want
(It is hard to see on the text version of this page, but each of these words has a space before and after it.)

Also, it's okay to have explanations or comments before or after the replacement section of the template wiki. If the line does not have a colon, it will not be a part of the template, but the rest of the template will work correctly. The last thing I want to mention is that, again, you can easily use the wiki's pseudo-html in your template too. For example, the following two template lines would work perfectly:

GREENDIVIDER:<img:http://elftown.eu/stuff/2237_wiki_help_9y7vcgcflr5>
TEMPLATEPAGE:[Template Help@wiki]

You'll note that these are all capitalized. This is a precaution so that people talking about their templatepage don't accidentally trigger the template.

The final step is to apply the template to a wiki. Any wiki you can edit can use any other wiki for a template. Once you've designed your template wiki, go to the wiki you want to use it on, and put at the top of that page "Template:nameofwiki". So, if we use the chesstemplate example, the first line of your wiki would look like this:

Template:chesstemplate

This line won't actually appear on the wiki, just in the edit box. Once you've done this, the wiki will now look at the template wiki. Any lines that have a colon in them will be used for replacement. Text before the colon in that line will be replaced by the text after the colon in that line. Keep in mind that if you use the 'preview' feature when editing your wiki, the template won't be visible. You will be seeing your page pre-template, but once you actually submit the changes, the template will kick in for anyone viewing the page.

<img:http://elftown.eu/stuff/2237_wiki_help_9y7vcgcflr5.jpg>


Go or return to:
-The wiki-index
-Elftown Technology
-The help index

Username (or number or email):

Password:

2011-05-02 [Aradon Templar]: If there are any questions, I'll try and address them down here, so please ask!

2011-05-05 [Aradon Templar]: ... Maybe I would have considered this information if I had known you guys had added a preview button :P

2011-05-05 [Aradon Templar]: Well we all know how often I hang around the wikis these days. Hopefully the bit I added at the end is clear: "Keep in mind that if you use the 'preview' feature when editing your wiki, the template won't be apparent. You will be seeing your page pre-template, but once you actually submit the changes, the template will kick in for anyone viewing the page."

2011-05-20 [Aradon Templar]: Hm. Is there a code you can use to tell a template to make a line break? For example, if I wanted to display a list of books I've read on several pages (for some reason) but wanted to only have to update one list, I could make a template for BOOKLIST, and just update the template page. But the template would look like: "BOOKLIST:1.(new line)2.(new line)" etc. Using enter would destroy the template format, and you'd just get the first line of the list. I feel like this is the <br> tag? Is that part of ET's pseudo html?

2011-05-20 [Aradon Templar]: Did some testing and reading. The <br> tag of course doesn't work, but if you need line breaks, you could probably get tables to work. Edit: Yes, the table method works, though my code "BOOKLIST:<table>1. --- 2. --- 3. --- 4. </table>" turned into "BOOKLIST:DH1130811HD" inexplicably on the template page. On the receiving page, it displayed the list with the desired line breaks.

2011-05-20 [Aradon Templar]: Cool, thanks.

2011-06-20 [Veltzeh]: Could this page have keywords so it would be easy to find with the search function? :)

2011-06-20 [Aradon Templar]: Yes, but first I will grumble about Elftown's fancy wikitools.

Show these comments on your site

Elftown - Wiki, forums, community and friendship.