Bureaucrats, content-moderator, emailconfirmed, Administrators (Semantic MediaWiki), Curators (Semantic MediaWiki), Administrators, threadmoderator
85,404
edits
Line 75: | Line 75: | ||
Parser functions are magic words that get the wiki software to perform an action upon a string (that is a set of letters, numbers and/or symbols) in order to return a result. Explaining all their possible functions is well beyond this scope of this help page. | Parser functions are magic words that get the wiki software to perform an action upon a string (that is a set of letters, numbers and/or symbols) in order to return a result. Explaining all their possible functions is well beyond this scope of this help page. | ||
However, there are two major type of parser function, conditional and non-conditional. A condtional function is one that results in an action based upon some sort of if/then/else logic. Here's a list of conditional functions with a very basic explanation of each: | However, there are two major type of parser function, conditional and non-conditional. | ||
====Conditional function==== | |||
A condtional function is one that results in an action based upon some sort of if/then/else logic. Here's a list of conditional functions with a very basic explanation of each: | |||
*<tt><nowiki>{{#expr:</nowiki> ''expression'' <nowiki>}}</nowiki></tt> (evaluates the given expression; see [[wikipedia:Help:Calculation]]) While not strictly conditional, it's often nested within a conditional statement so as to answer the question, "If the result of this calculation is ''something'', then take this action; otherwise, do this other thing." | *<tt><nowiki>{{#expr:</nowiki> ''expression'' <nowiki>}}</nowiki></tt> (evaluates the given expression; see [[wikipedia:Help:Calculation]]) While not strictly conditional, it's often nested within a conditional statement so as to answer the question, "If the result of this calculation is ''something'', then take this action; otherwise, do this other thing." | ||
Line 93: | Line 96: | ||
#'''<nowiki>":''For other uses . . . "</nowiki>''' is the event we want to happen if the first two things are equal | #'''<nowiki>":''For other uses . . . "</nowiki>''' is the event we want to happen if the first two things are equal | ||
#'''"|}}"''' says "if the first two things are unequal do nothing". If we wanted the code to take a positive action on inequality, we'd type something between the pipe and the curly brackets. So, we could write: <nowiki>{{#ifeq:|{{PAGENAME}}|Doctor Who (1996)|:''For other uses of the name ''Doctor Who'', please see [[Doctor Who (disambiguation)|This is not Doctor Who (1996)}}</nowiki> But that would be rather silly. | #'''"|}}"''' says "if the first two things are unequal do nothing". If we wanted the code to take a positive action on inequality, we'd type something between the pipe and the curly brackets. So, we could write: <nowiki>{{#ifeq:|{{PAGENAME}}|Doctor Who (1996)|:''For other uses of the name ''Doctor Who'', please see [[Doctor Who (disambiguation)|This is not Doctor Who (1996)}}</nowiki> But that would be rather silly. | ||
====Non-conditional==== | |||
Non-conditional parser functions have exactly the same syntax as conditional functions, but they don't actually depend on if/then logic to produce the result. No attempt will be made here to even list all the possible parser and string functions. But we will examine one example: '''#titleparts'''. | |||
This function separates a pagetitle into segments based on slashes, then returns some of those segments as output. | This function separates a pagetitle into segments based on slashes, then returns some of those segments as output. | ||
Line 116: | Line 119: | ||
And, indeed, most of the value of parser functions is not in their use on an individual page. Rather, they are the building blocks for coding templates that automatically find, manipulate, and most importantly '''link to''' information on ''any'' page. | And, indeed, most of the value of parser functions is not in their use on an individual page. Rather, they are the building blocks for coding templates that automatically find, manipulate, and most importantly '''link to''' information on ''any'' page. | ||
===Detailed info on magic words=== | ===Detailed info on magic words=== | ||
If you want to explore the world of template coding with magic words such as parser functions, there are a few pages you'll want to look at. | If you want to explore the world of template coding with magic words such as parser functions, there are a few pages you'll want to look at. |
edits