|
| ||||||||||||||||||||
Benedict
|
[Help] Parser Function Guide - Updated (ifexist, 28th Oct) | |||||||||||||||||||
![]() TOC: 1. Introduction 2. #if: 3. #expr: 4. #ifeq: 5. #ifexpr: 6. #ifexist: This thread was suggested by Torterra93/BadWolf/Lykerok/Dragoon/Shayn and been at the back of my mind for ages. So I decided to create it. Parser Functions are an extension to Wiki Templates' Magic Words. (Doc On mediawiki) Parser Functions are (in a wiki case) functions that are for use with wiki Templates. They are also, alongside String Functions, the main coding used in wiki guides' template auto alongside the other templates on that wiki. (Doc On mediawiki) String Functions are like Parser functions, basically an extension. They won't be covered in this post. #if {{#if:}} is one of the standard parser functions that can become confusing, due to the first part of the usage syntax could be either {{{something}}} or {{{something|}}}. The below is copied of Mediawiki. When using {{{something}}}:
When using: {{{something|}}}:
You would normally use the latter. Examples:
#expr {{#expr:}} evaluates a mathematical expression and returns the calculated value. You can use: ( ) or, and = != <> > < <= >= round + - mod,* / div,^ not ceil trunc floor abs ln sin cos tan acos asin atan e As your expr operators. The rest can be numbers. Examples:
You can also do multiple sums in one usage.
#ifeq The {{#ifeq:}} parser function compares two strings and determines whether they are identical.
Note that the comparison is case sensitive. The examples below are the easiest way to show what they do and how to use them. Examples:
Basically, anything other than "here" in that example would output Bye!
Because the comparison is case sensitive. #ifexpr This function evaluates a mathematical expression and returns one of two strings depending on the value of the result. It is basically ifeq and expr combined, only limited to using > and < etc. Examples:
{{#ifexpr: test > foo|bar|Yep|Nope}} will generate Expression error: Unrecognised word "test" however. If you want to use something other than > or < then use something like this syntax:
What I've done so far is only the start. Two more posts below this will be made for switch, ifexists, replace (string function), time and prehaps a few others. This is because the maximum number of code tags in one post is ten. I may have made some mistakes so feel free to point them out. Also I'll be happy to answer questions, so post em if you want! ![]() [size=1][color=#666666]This message was edited by Benedict on Oct 28 2009. ------------------- | ||||||||||||||||||||
quote quick quote edit quick edit del posts in thread report
| ||||||||||||||||||||
Benedict
|
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct) | |||||||||||||||||||
{{#ifexist:}} is a parser function that you probably won't use on the Wikis, but I decided to cover it anyway This function takes the first inputted string and checks to see if it is a made page. As long as the page does not have a red link, it will return what is in the second parameter, and if it doesn't exist, will return what is in the third parameter.
It can also work with Special Pages and System Messages as long as they are set (created) which most system pages on the wikis arn't. System Messages are pages with the namespace Mediawiki: such as Mediawiki:Common.css, or Mediawiki:Sitenotice. If you use too many on one page then it will trigger something that will automatically produce the "value if doesn't exist" on a page. read more here. You can't use this across wikis, ie check that Forest Temple on the Zelda wiki has been created on, say, the Death Note wiki. When checking for images the extension has to be correct. Examples: All these examples are on the Pikmin neowiki, and their created status are at the time of writing so deletions and creations may have been made in the meantime.
![]() [size=1][color=#666666]This message was edited by Benedict on Oct 28 2009. ------------------- | ||||||||||||||||||||
quote quick quote edit quick edit del posts in thread report
| ||||||||||||||||||||
Benedict
|
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct) | |||||||||||||||||||
![]() ------------------- | ||||||||||||||||||||
quote quick quote edit quick edit del posts in thread report
| ||||||||||||||||||||
Benedict
|
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct) | |||||||||||||||||||
Anyway, that took about 30 mins. I made the image btw. You can post now lol ![]() ------------------- | ||||||||||||||||||||
quote quick quote edit quick edit del posts in thread report
| ||||||||||||||||||||
Dragoon
|
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct) | |||||||||||||||||||
|
Dude this is great, I understand it alot more than reading through mediawiki. (y)
------------------- | ||||||||||||||||||||
quote quick quote edit quick edit del posts in thread report
| ||||||||||||||||||||
Benedict
|
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct) | |||||||||||||||||||
![]() ------------------- | ||||||||||||||||||||
quote quick quote edit quick edit del posts in thread report
| ||||||||||||||||||||
| [All dates in (PT) time] | Threads List « Next Newest Next Oldest » | |||||||||||||||||||
Powered by neoforums v0.9.7g (equilibrium)
Copyright Neo Era Media, Inc. 1999-2009