Login / Create Account

wiki:Internal Functions

< Documentation

Contents [hide]

Decision-Making Functions

#if

syntax: {{#if: condition|then|else}}

  • Examples:
    • {{#if: {{{1|}}}|{{{1}}}|none}} - displays the first parameter if the first parameter is defined and is not blank, else it displays none.
    • {{#if: {{{2|}}}|{{{2}}}|{{{1}}}}}

#ifeq

syntax: {{#ifeq:value1|value2|code if equal|code if not equal}}

  • NOTE: leading and trailing spaces in value1 and value2 are significant in this function!

#ifexist

syntax: {{#ifexist: pagename|then|else}}

  • Returns True if the page exists.
    • game db wiki namespace references will return True if the db entry OR the wiki text exists.

#ifexistwiki

  • Rationale: #ifexistwiki, coupled with #ifblank, would allow us to do things, or specifically NOT do things, in the pre and post templates dependent on the wiki text record existing and being not blank. It would also allow us to auto-categorize all db entries that have NO wiki text, helping us to locate records in need of CM love.
syntax: {{#ifexistwiki:game_id|db_name:pagename|then|else}}
  • Returns True only if the wiki text record for the referenced game db entry exists.
  • Note: To test the existence of the db half, use #db with the id field. ALL db pages must have this, so #db will return nothing (false) if the db entry does not exist!

#ifblank

syntax: {{#ifblank:pagename|then|else}}

  • Returns True if the wiki text record for pagename is blank or is not defined.

#switch

syntax: {{#switch: target|value1|valuen...=output|valuea|valuez...=output|default_output}}

  • This is like a case statement.

String Manipulation Functions

#replace

syntax: {{#replace:string|regex|value}}

  • Replaces characters matching regex in string with value, where the delimiter is defined by regex. This is NOT a full regex line, it is a mask. If you were writing regex, this would be the pattern matching portion of that.
  • For a definition and simple reference of regex, see this article at Wikipedia
  • Pipe ("|") can be used as a delimeter by using &#124; for the value of regex

#explode

syntax: {{#explode:string|regex|n}}

  • Returns the nth (BASE 0) "word" in string, where the delimiter is defined by regex. This is NOT a full regex line, it is a mask. If you were writing regex, this would be the pattern matching portion of that.
  • If regex is null, #explode returns nth character, not nth word!
  • Use \s for space, so {{#explode:This is a test|\s|1}} should return: is
  • If n is negative, distance is measured from the end of the string.
  • Space is tricky to define, so space is the default delimiter.
  • Negative values for n will return the nth "word" from the end.
  • Pipe ("|") can be used as a delimeter by using &#124; for the value of regex

Examples:

  • {{#explode:This is a test|\s|2}} returns: a
  • {{#explode:This is a test|\s}} returns: This
  • {{#explode:This is a test|\s|-1}} returns: test
  • {{#explode:x,y,z|,|0}} returns: x
  • {{#explode:bippity,boppity,boo|,|1}} returns: boppity

Case Manipulation Functions

uc:

syntax: {{uc:string}}

  • Converts all of string to upper-case

lc:

syntax: {{lc:string}}

  • Converts all of string to lower-case

ucfirst:

syntax: {{ucfirst:string}}

  • Converts the first character in string to upper-case

lcfirst:

syntax: {{lcfirst:string}}

  • Converts the first character in string to lower-case

PageName Manipulation Functions

A PAGENAME has the format Name Space:Page Name (Suffix)

See also: Templated Extensions#PAGENAME Manipulation

NAMESPACE

syntax: {{NAMESPACE}}

  • Returns Name_Space, if any, without the colon, and with any spaces replaced by underscores.

PAGENAME

syntax: {{PAGENAME}}

  • Returns Page Name (Suffix), devoid of any Name Space.

PAGENAMEE

syntax: {{PAGENAMEE}}

  • Returns Page_Name_(Suffix), devoid of any Name Space, with all spaces replaced with underscores.

Database Access Functions

See Database Layouts for a list of tables and fields that can be referenced with the following functions.

#db

Dependant on the specific game database, but the general form is:
syntax: {{#db:game_id|db_name|record_title|field_name}}

  • returns the value stored in field field_name from the game_id db_name record with the title of record_title.
  • example: {{#db:eq2|zones|East Freeport|type}} would return City.

#dblist (proposed)

syntax: {{#dblist:game_id|db_name|record_title|relation_name}}

#dbullist (proposed)

syntax: {{#dbullist:game_id|db_name|record_title|relation_name}}

  • returns an unordered list of records related to the record identified with record_title.
  • example: {{#dblist:eq2|zones|Sebilis|zones}} would return:

#image

syntax: {{#image:page_name|n}}

  • returns the image system id number of the top-most image attached to page_name, or the nth from the top if n is defined.
  • example: [[image:{{#image:}}]] will display the top image of the current page. This is exactly the same as if n were 1.
  • example: [[image:{{#image:EQ2 Mob:a cow}}]] will display the top image of a cow.
  • example: {{#if:{{image:|2}}|[[image:{{#image:|2}}]]}} will display the 2nd image of the current page, if there is one.

#category (Proposed)

syntax: {{#category:category_name}}

  • Returns true if the current page is a member of category category_name
  • Rationale: With this function, coupled with a new pre and post template set (Wiki and Wiki Bottom) to be prepended or appended to all wiki pages, we can test for the game category and auto-display relevant data such as a copyright notice on the bottom of all EverQuest and EverQuest II pages.

Pre and Post Templates

This section really belongs on a different help page, but I am parking the information here for now. -Bludwyng

Because our Wikibase™ is an integration of Wiki and Database, we have a few special things to help us. For each game db in the system that is wikified, there is a pair of special templates that will be prepended or appended to the user-editable wiki text before the page is compiled. These allow us to do things like auto-generating category links and displaying the DB content within the wiki frame. The following is just one example:

For the EverQuest II game, for the mob database:


Tytania
The Relentless
Fae Wizard
Lucan D'Lere
EverQuest II
Bludwyng, ZAM Network Sr. Wikibase Admin Send a private message to Bludwyng
All the power in the universe in a small, flaming fairy, package.



© Zam Network LLC. Some content is licensed under the GNU Free Documentation License. Privacy Policy Terms of Service.