This Forum has been archived

Visit the new Forums
Forums: Index Support Requests Template Functions, Variables, etc help
FANDOM's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.

50px-Replacement filing cabinet.svg

Note: This topic has been unedited for 2176 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.

Hi, I've been researching and and amongst many other searches and I've picked up lots of useful functions to use, particularly in creating a Preloaded New Page Template. I've also been studying up on Excel and extracting relevant data from cells to operate with. Some things I haven't found an answer to yet that I need to make my template work:

  1. Is there any way to have a Infobox-type-template popup window prompt the user for what format data it expects to be enterred? eg: I want a user to input a Cost Type of Dollars or Piastres and have the Infobox display $ or €, but how do I say "enter P or 2 for Piastres and D or 1 for Dollars"?? So I have made this code to detect carious ways of the user enterring the type: {{#switch:{{{Cost Type €/$}}}|p|P|€|2=€|d|D|$|1=$|$}} But even then it will fail if they enter "Piastre" or "money2" or anything else... Shouldn't there be a way to prompt the user without making it part of the {{{Variable Name}}}?
  2. I know in Excel how to extract the first character of a cell, but how can I truncate a wiki variable input? In the above example, say a user enters "Piastre", I want to be able to: {{#switch:{{#TRUNCATE:{{{Cost Type €/$}}}|1}}|p|P|€|2=€|d|D|$|1=$|$}} so I only have to #switch: the first character.
  3. The above example has #switch: insert a $ by default if there is no match, but in general for variables, say {{{RepairMultiplier|0.2}}} would insert 0.2 if no user input is enterred, but the fields in the popup are all blank. Can't we make the popup show the default values, so the user (not just the coder) knows which fields are pre-filled by defaults so they know they don't have to fill them in unless they need changing.
  4. Depending on whether the output of {{#switch:{{{Cost Type €/$}}}|p|P|€|2=€|d|D|$|1=$|$}} is € or $ I want to do different calculations on other variables (and this is just one example of variables and formulas I want to do in my page-creation-template, so rather than having dozens of dozens of lines nesting the same if/switch statments is there a way to input data into a variable without doing through a user popup box? eg:

VAR:CostSymbol={{#switch:{{{Cost Type €/$}}}|p|P|€|2=€|d|D|$|1=$|$}} and {{IF CostSymbol = "€" | VAR:BaseCost = {{exp 1100 * {{{PurchasePrice|1000}}} }} | VAR:BaseCost = {{{PurchasePrice|1000}}} }}
So then later: I can do operations and output to cells:
|'''Repair Cost:''' (new line) | $ {{expr BaseCost * {{{RepairMultiplier}}} }}
And then 5 subsequent lines with "Level 1" and the above * 1.7 etc, and other columns with similar formulas. I'd much rather lines like that rather than nesting everything like:
|'''Repair Cost:''' (new line) | $ {{expr {{IF {{#switch:{{{Cost Type €/$}}}|p|P|€|2=€|d|D|$|1=$|$}} = "€" | {{exp 1100 * {{{PurchasePrice|1000}}} }} | {{{PurchasePrice|1000}}} }} * {{{RepairMultiplier}}} }}
in about 50 cells for the first simplified page...

Any suggestions?

Dollars_small.pngDarkMoonRisingtalkcontribs11:02, June 30, 2012.

About how to truncate a word, you can use the StringFunctions. I'm not able to help you on the other matters, sorry. leviathan_89 11:22, 30 June, 2012 (UTC)

Thanks so much, 1 down, 3 to go! So to ignore anything past the first character and ouput a currency symbol I've now got this code:

{{#switch:{{#sub:{{{Cost Type €/$}}}|0|1}}|p|P|€|2=€|$}}

Still, going to be annoying to have to use a 3-line-long expression in 50+ cells if there is no method of defining a variable outside of a popup box.

Dollars_small.pngDarkMoonRisingtalkcontribs14:08, June 30, 2012.

Oooh - I just stumbled across this myself: mw:Extension:Variables and other interesting links from the page: Help:Parser functions#Other Extensions

Dollars_small.pngDarkMoonRisingtalkcontribs03:48, July 07, 2012.

If Extension:Variables is permissible by Wikia, I'd very much like to know -- 05:01, July 7, 2012 (UTC)
Permissible? I don't understand. I'm still new to advanced wikia editing, but I understood mediawiki is a wiki package used by wikia, and the links to it was from wikia pages, so I do not understand "if a mediawiki extension is permissible by wikia"?
Dollars_small.pngDarkMoonRisingtalkcontribs05:14, July 07, 2012.
Hmmm, so do you mean although w:c:ParadiseIslandHD:Special:SpecialPages tells us MediaWiki v1.16.5 is installed, wikia does not use all its extension? That's ridiculous, it would reduced significantly pages of mess of recursive template calls on pages needing extensive calculations based on variables. I just tried a simple one on My Sandox - didn't do anything. How can we use Extensions please??? Obviously by the comment above, there would be many many others who would want this (and probably others) extension enabled!!
Dollars_small.pngDarkMoonRisingtalkcontribs05:26, July 07, 2012.

MediaWiki software extensions

Like all wikis, Wikia runs the core MediaWiki software. However, some features are not present in the core software, so they're written as "extensions" to the core software. These extensions have to be installed on the back-end by Wikia staff to work on your wiki.

  1. Some extensions are so important and useful that they are installed by default on all Wikia wikis. MW:Extension:ParserFunctions is a good example of this.
  2. Some extensions are unstable, so Wikia won't install them.
  3. Some extensions are incompatible with the version of MediaWiki software that Wikia operates on (currently 1.16.5, upgrade to 1.19 is in progress) and so Wikia can't install them.
  4. Some extensions are not installed by default, but they work just fine and Wikia may install them upon request, you just have to ask at Special:Contact.
  5. Wikia may of course refuse to install extensions for other reasons.

For a list of extensions which are installed on your wiki, see Special:Version. In any case, what he meant was whether or not Extension:Variables would be enabled by Wikia staff or if they would refuse to install it if you asked them to. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 05:43 UTC, Sat, 07 July 2012

Thanks for the explanation - as I said, I am still new to tweaking, and apparantly pushing the limits hard :) I'm getting the hang now of the hierarchy from a wikia site to wikia to wiki and the concept that wikia is just one wiki server controlled by wikia staff and each wikia site relies on the wikia presets, but can also add individual templates, functions, etc, such as collapsible tables, hidden navboxes, into common.css, common.js, etc. Even individual users can add their own edit buttons, etc. Huge learning curve.
I guess the answer is no, but can an extension, or parts of the extension, be added into individual wikia sites into the mediawiki css, js files? Or can they only be added globally on the server itself Dollars_small.pngDarkMoonRisingtalkcontribs06:09, July 07, 2012.

Wikis and Web Development: What's What

You may find wikipedia:MediaWiki, mw:Manual:Extensions and mw:Manual:Developing extensions to be good reading material to help satisfy your curiosity. Additionally, here's a wall of text for you =)

Here's a basic overview of web development and how Wikia fits in to it:

  1. Webpages are always structured using HyperText Markup Language (HTML)
  2. HTML elements can be stylized using Cascading Style Sheets (CSS)
  3. Webpages can be made to interact with the user, a concept known generally as Dynamic HTML.

The MediaWiki software is written in the PHP programming language -- which is a server-side scripting language. It is essentially a translator that translates the Wiki Markup we write into the HTML that actually makes the document you're reading right now. The idea behind wikis is that it's convenient for mass-content-generation to provide the Wiki Markup language, because it's a heck of a lot easier to learn and use than HTML + CSS.

All MediaWiki "Extensions" are also written in PHP. So to answer your question, no, it's impossible for you to add an extension in whole or in part to your wiki. Wikia staff have to do it to the server on the back-end.

By contrast, the front-end stuff is what you, as a wiki editor, can control. That includes:

  1. The Wiki Markup you use as a wiki editor -- e.g. templates, nav boxes, magic words, etc.
  2. Certain HTML which MediaWiki software allows (not all HTML is allowed on wikis, see wikipedia:Help:HTML in wikitext for more info)
  3. CSS which can be used to further stylize content -- this is getting into the "advanced" part of things. Most wiki editors do not know CSS.
  4. JavaScript which can be used to make webpages dynamic (see my note about DHTML above) -- this is really getting into the advanced part. Only a small fraction of wiki editors have the slightest idea about JavaScript. In fact, the large majority of wiki administrators only know how to copy JavaScript "scripts" and apply them to their wiki at MediaWiki:Common.js. And many admins don't even know that much.

You're right, a lot of this stuff is complicated. That's the nature of web development. The reason you're encountering this "huge learning curve" is because you're trying to level up beyond the basics of wiki markup. Most wiki editors don't. Because there's a lot to learn! Every person you've ever met on a wiki is still in the learning process, even Wikia staff themselves! 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 06:53 UTC, Sat, 07 July 2012