Wiki:Internal Functions
| 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.
- 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
- For a definition and simple reference of regex, see this article at Wikipedia
#explode
syntax: {{#explode:string|regex|n}}
- Returns the nth "word" in string, where the delimiter is defined by regex
- If n is negative, distance is measured from the end of the string.
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: {{uc:string}}
- Converts the first character in string to upper-case
lcfirst:
syntax: {{uc:string}}
- Converts the first character in string to lower-case
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
syntax: {{#dblist:game_id|db_name|record_title|relation_name}}
- returns a comma-delimited list of records related to the record identified with record_title.
- example: {{#dblist:eq2|zones|Sebilis|zones}} would return: The Crypt of Agony,Kunzar Jungle,Protector's Realm,Venril Sathir's Lair
#dbullist
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:
#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.
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:
- EQ2 Mob - Prepended to the wiki content
- EQ2 Mob Bottom - Appended to the wiki content
![]() | Bludwyng, Allakhazam Sr. Wikibase Admin | |
| Links: Bludwyng's (Templates/Global Templates/Pages/Guides/Contribs) - EQ2 Main Page | ||
| "Fear my evil cuteness!" | ||
Home