Computer HardwareXbox GamesGameCubePlaystation 2PSOnePC/Windows GamesGameboy AdvanceDreamcastNintendo 64Gameboy ColorNintendo DSSony PSPXbox 360Nintendo Wii GamesPS3 Games

Neoseeker Forums » NeoWikis » NeoWiki Best Practices and Help » [Help] Parser Function Guide - Updated (ifexist, 28th Oct)

Moderated by: Krunal
REPLY TO THIS THREAD   START NEW THREAD
Options: Print   subscribe   remove   send to friend   PM this thread to a friendNeoPM
subscribe to thread Topic: [Help] Parser Function Guide - Updated (ifexist, 28th Oct)
Benedict
short = sweet
Neolithic

wiki staff
pikmin




Benedict's profileBenedict's neohomeNeoPM BenedictBenedict's gallery (9 images)
total posts: 6296
neopoints: 200
since: Oct 2007
Oct 27, 09 at 3:43pm
[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}}}:
    code
    {{#if: {{{1}}} | Parameter 1 is not defined, or is defined and non-null/non-empty. | Parameter 1 is defined, but null. It contains only empty string(s) or breaking space(s) etc.}}
    


    When using: {{{something|}}}:
    code
    {{#if: {{{1|}}} | Parameter 1 is defined and non-null/non-empty. | Parameter 1 is not defined, or is defined but null. It contains only empty string(s) or breaking space(s) etc.}}
    


    You would normally use the latter.

    Examples:

    code
    {{#if: {{{name|}}} | Hello {{{name}}}! | Hello guest!}}
    And so:
    
    {{Template:Name
    |name=Luke
    }}
    Would output:
    
    Hello Luke!
    
    Whereas:
    {{Template:Name}}
    
    Would output:
    
    Hello Guest!
    


    #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:
    code
    {{#expr: 300 + 500}}
    Outputs
    800
    

    You can also do multiple sums in one usage.

    code
    {{#expr: 1 + 1 + 1 + 1 - 1}}
    Outputs
    3
    


    #ifeq


    The {{#ifeq:}} parser function compares two strings and determines whether they are identical.
    code
    {{#ifeq: string 1 | string 2 | output/value if both are same | output/value if both are not the same }}
    


    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:
    code
    {{#ifeq: {{{1}}}|Here|Hi!|Bye!}}
    
    {{Template|Here}}
    would output
    Hi!
    
    Whereas
    {{Template|blah}}
    would output
    Bye!
    


    Basically, anything other than "here" in that example would output Bye!

    code
    {{#ifeq: test | Test | Yep | No }}
    
    would output
    
    No
    

    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:
    code
    {{#ifexpr: 3 > 750|It is  Larger!|It is Smaller!}}
    Outputs:
    It is Smaller!
    


    {{#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:
    code
    {{#ifeq: {{#expr: 3+3 }} | 6 | 3 add 3 is six | 3 add 2 is not six }}
    



    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  searchposts in thread  report
Benedict
short = sweet
Neolithic

wiki staff
pikmin




Benedict's profileBenedict's neohomeNeoPM BenedictBenedict's gallery (9 images)
total posts: 6296
neopoints: 200
since: Oct 2007
Oct 27, 09 at 3:43pm
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct)

    #ifexist


    {{#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.

    code
    {{#ifexist: page title | value if exists | value if doesn't exist }}


    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.
    code
    {{#ifexist: Spotty Bulbear | exists | doesn't exist }} -> doesn't exist
    {{#ifexist: Burrowing Snagret | exists | doesn't exist }} -> exists
    {{#ifexist: Mediawiki:Common.css | exists | doesn't exist }} -> doesn't exist
    {{#ifexist: Image: Bulbmin.jpg | exists | doesn't exist }} -> exists
    



[size=1][color=#666666]This message was edited by Benedict on Oct 28 2009.


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Benedict
short = sweet
Neolithic

wiki staff
pikmin




Benedict's profileBenedict's neohomeNeoPM BenedictBenedict's gallery (9 images)
total posts: 6296
neopoints: 200
since: Oct 2007
Oct 27, 09 at 3:44pm
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct)

    Reserved for more complex parser functions and string functions such as explode, replace, etc.


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Benedict
short = sweet
Neolithic

wiki staff
pikmin




Benedict's profileBenedict's neohomeNeoPM BenedictBenedict's gallery (9 images)
total posts: 6296
neopoints: 200
since: Oct 2007
Oct 27, 09 at 3:46pm
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct)

    Reserved for extra post space if I need it, etc. May delete if I don't need the extra 10 code tags this post can provide.

    Anyway, that took about 30 mins. I made the image btw.

    You can post now lol




-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
Dragoon
*sadface*
Still Seekin'

wiki staff
deathnote
doctorwho




Dragoon's profileDragoon's neohomeNeoPM Dragoon
total posts: 3510
neopoints: 165
GameGrep pts: 420
since: Mar 2009
Oct 27, 09 at 3:50pm
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  searchposts in thread  report
Benedict
short = sweet
Neolithic

wiki staff
pikmin




Benedict's profileBenedict's neohomeNeoPM BenedictBenedict's gallery (9 images)
total posts: 6296
neopoints: 200
since: Oct 2007
Oct 27, 09 at 3:52pm
re: [Help] Parser Function Guide - Updated (ifexist, 28th Oct)

    heh, and NAMfox isn't messing it up like it would if it were PHP tags. Well, that bug might oh been fixed acutally.


-------------------
quote   quick quote   edit   quick edit   del  searchposts in thread  report
[All dates in (PT) time]Threads List   « Next Newest   Next Oldest »
REPLY TO THIS THREAD   START NEW THREAD


search:
Neoseeker Forums » NeoWikis » NeoWiki Best Practices and Help » [Help] Parser Function Guide - Updated (ifexist, 28th Oct)



Jump to another forum:

Powered by neoforums v0.9.7g (equilibrium)
Copyright Neo Era Media, Inc. 1999-2009

neoseeker forum community
Neoseeker.com   |   Forum Rules   |   Forum FAQ   |   Neoseeker Terms of Use   |   Supermods On Duty [ server id: ascension ··· elapsed: 0.1566789150]
Affiliated sites:   GameGrep - Football Manager Wiki - Halo Wiki - MGS Wiki - GTA Wiki - Smackdown Wiki - Zelda Wiki - PS2seeker - Xbox seeker - DEVPEN - GFXcess