User:Anpang/sandbox

Archives: Archive 1 (Timeline, template, #switch function tests) Archive 2 (Styled requests for adoption boilerplate) This is version/archive 3 of my sandbox. My alternative sandbox: Directory sandbox testing: new User:Anpang/u

 Go Back My Userboxes and Templates example some explainations go here example more explainations go here

Template:Userlinks but with ALL of the logs (excluding user creation because its useless)

User: (meta talk | meta contribs | abuse log | abuse log | block log | content model change log | dump log | delete log | wiki creation/farmer log | global accounts log | global block log | global rename log | global rights log | abuse log | import log | incident reports log | interwiki log | managewiki log | massmsg log | merge log | move log | oauth consumer log | create page log | translate log | patrol log | protect log | removepii log | tags log | tags manage log | thank log | translation review log | upload log | user merge log | rename user log | user rights log | centralauth | rights changes)

User account "Anpang" is not registered.

There is currently no text in this page. You can search for this page title in other pages, search the related logs, or create this page.

index

a currently testing: full guide to making templates

Full Guide to Making Templates

First of all, what are templates? Well, for example, you have 10 pages that use the exact same content, just changed up a bit. Well yes, you can fill them up manually, but 1. takes up more server space and 2. you need more time. The perfect thing to solve that are these things called templates. Templates are usually put in the Template namespace or subpages in the User namespace, however other templates in the (Main) namespace, File namespace, Talk namespaces, etc can also be found, but very rare and not recommended at all.

Creating your first template

Want to create your first template now? Well, of course you'll need a topic first. In this example, I'll make a template that is text "Tigers are animals and they are really scary." Now click here and open it in a new tab. That is your sandbox page. You can test templates in there. If you haven't created the page yet, create it.

For my example, I want a template that says "Tigers are animals and they are really scary.", so in that page, I put in that text. Now I go to another page and put  (replace YOURUSERNAME with your meta username). If things work correctly, the text that you've put in there should be displaying in that page that you've just put the template in.

Parameters

Now, I want my template to not just say "Tigers", I want it to say "Piranha" or "Shark" too. Well yes, again, I could just make seperate templates for all those 3 animals, but that's not very efficient, Introducing, parameters! I can add a parameter like this:

What does that do you might ask? Well, the means a "parameter". A parameter is like a variable. Now, instead of using the template as, it is used like this:. I put "Piranha" in there so it displays piranha. I can put "Shark" in there and it will display as "Shark".

Default values in parameters

In the parameter code, I put "|Tigers". What does that mean? Well, if the user that put the template didn't put any "Piranha" or "Shark" or "Tigers" text, it will result in "Tigers". It's the default value of that parameter.

If I put, it will display Tigers because I set tigers as the default value.

#switch

For example, I want to shorten the usage code of the template a bit. Instead of |Shark, I'd like it to be |s and it will still display Shark. That's very easy! This code does it:

I just need to simply replace the  with that code. The default value is still Tigers and it works!

The code is now this:

By the way, if you think your #switch code is a bit messy and mixed up, you can also do it in multiple lines, something like this:

#ifeq & #if

Another parser function, #ifeq, is used to compare 2 values together and see if it's equal. It's syntax is:

In the example, obviously, Text1 isn't identical to Text2, and the parser function will display "different". But if I change the 2 of the 2nd value to a 1, now the parser function will display "same".

You can also use parameters, something like this:

If the parameter is "p", it will display Piranha. Else, it will display Shark. You can also put ifeqs into other ifeqs, basically making an if else thingy.

See where this is going? You can basically make if else statements telling if something is equal. HOWEVER, did you realize that this is quite similar to #switch. That's why #ifeq isn't commonly used.

The #if parser function is even more useless than the #ifeq function. It basically checks if a string exists. It's syntax is like this:

#iferror & ifexist

Now for a useful parser function, #iferror. Some of your parser functions or even just normal text fomatting can go wrong and cause an error. You know, when functions go wrong, they become big bold red text. The way for the page to detect them by themselves is #iferror. Syntax is this:

Another kinda useful parser function here, #ifexist. This function checks if a specified page exists. The syntax is:

Here's some examples:  returns Page exists!

Substitution

...