Help:Editing manual: Difference between revisions

Jump to navigation Jump to search
7,639 bytes removed ,  16 October 2023
No edit summary
Line 98: Line 98:
{{InfoBlob|<nowiki>| alt-name = Model</nowiki><br>
{{InfoBlob|<nowiki>| alt-name = Model</nowiki><br>
<nowiki>| alt-image = [[File:Character_name_Model.png|200px]]</nowiki>}}
<nowiki>| alt-image = [[File:Character_name_Model.png|200px]]</nowiki>}}
== Templates ==
A '''Template''' is a special type of page designed to be included within other pages. Templates are often used as 'shorthand' to automatically insert frequently-used images, code, and formatting on a page. We use templates extensively on bg3.wiki.
See the [[Help:Template Quick Reference|Template Quick Reference]] for an overview of the most commonly-used templates, or continue reading for examples of various templates.
Templates are powerful tools and can become very complex. For a much more in-depth look into templates, see [https://www.mediawiki.org/wiki/Help:Templates MediaWiki Help:Templates].
=== Page creation templates ===
We use templates like [[:Template:WeaponPage|WeaponPage]] to maintain a clean, consistent style across a large number of pages that share similar properties, such as [[Spell]]s, [[Weapon]]s, and other [[Equipment]]. These templates take your input in the form of standard parameters and use it to generate a pre-formatted page, optimise the page for search engines and embedded social media links, and add the page to the appropriate categories.
Examples:
* {{SmallIcon|Worgfang Icon.png}}[[Worgfang]] and {{SmallIcon|Everburn Blade.png}}[[Everburn Blade]] were created using [[:Template:WeaponPage]]
* {{SmallIcon|The Jolty Vest Icon.png}}[[The Jolty Vest]] and {{SmallIcon|Amulet of Lost Voices Icon.png}}[[The Amulet of Lost Voices]] were created using [[:Template:EquipmentPage]]
* {{SmallIcon|Potion of Speed Icon.png}}[[Potion of Speed]], {{SmallIcon|Throwable_Smokepowder_Satchel_Icon.png}}[[Smokepowder Satchel]], and {{SmallIcon|Book Thay A Item Icon.png}}[[Necromancy of Thay]] were created using [[:Template:MiscItemPage]]
Another great benefit of this approach is that it allows us to populate database tables with the provided information. For example, every time you add a new item to the wiki using the appropriate page template, it automatically adds the item to a database table which can be queried from elsewhere. This is, for example, how the lists on weapon type pages like [[Longswords]] are generated.
=== Data querying templates ===
When information is added to the wiki using an appropriate page creation template, the information is also made available in a database table. These tables can be queried from other pages, to display the data there as well, instead of having to link the user to the original page, or having to copy-paste the content.
For example, when you visit the page of a spell that inflicts [[Bleeding (Condition)|Bleeding]], you want to see the effects of the condition right then and there, instead of having to navigate to another page. If we copy-pasted the description of the condition into every page that mentions it, we would have a lot of work to do if a patch for the game changed how the condition works! For this reason, the condition is defined once, using the [[Template:ConditionPage|Condition Page]] template, and other pages query the data to display it.
Writing these queries can be quite complicated. So, the wiki offers templates that do the heavy lifting for you. A primary example is the [[Template:Condition|Condition]] template, which you provide with the name of a condition, and it queries the data for you, displaying the effects of that condition in a nice format.
=== Other templates ===
Other templates can be used in a more focused fashion to insert frequently used, pre-formatted information or to add visual flair to a page, such as <code><nowiki>{{MediumArmour}}</nowiki></code> ({{MediumArmour}}) or <code><nowiki>{{action|bonus}}</nowiki></code> ({{action|bonus}}). These types of templates are often embedded within other, larger templates like Page Creation Templates, but they can and should also be used on their own where appropriate.
Additional template examples:
* [[Template:CharacterInfo]] can generate character infoboxes for Companions, NPCs, and other creatures.
* [[Template:Ability]] and [[Template:Class]] can add formatted Ability Scores and Classes, like so:
** {{Ability|Strength|20}}, {{Class|Cleric}}
* [[Template:SAI]] for '''S'''pell and '''A'''ction '''I'''con Links. Like so:
** {{SAI|Magic Missile}}, {{SAI|Frenzied Strike}}
* [[Template:ItemIcon]] and other templates in that family, such as [[Template:RarityItem]]. Like so:
** {{RarityItem|Dagger +1}} for a rarity border use {{InfoBlob|<nowiki>{{RarityIcon|Dagger +1}}</nowiki>}}
** {{SmItemIcon|Dagger +1}} for a simple iconlink use {{InfoBlob|<nowiki>{{SmItemIcon|Dagger +1}}</nowiki>}}
=== Using templates ===
==== Add a template to a page ====
[[File:visual_editor_template.png|right|thumb|Inserting a template with the Visual Editor]]
* When using the Visual Editor, select '''Insert''' &gt; '''Template''' from the toolbar and start typing a template name. The visual editor may not always display documentation for the template or its parameters, so be sure to open the template's page for usage information.
* When using the Source Editor, you can either copy and paste template code from an existing page, or newly invoke a template you're already familiar with by enclosing the template name in {{code|<nowiki>{{double curly braces}}</nowiki>}}. For example:
** Code: {{code|This attack has <nowiki>{{Advantage}}</nowiki>}}
** Result: This attack has {{Advantage}}
==== Template parameters ====
Some templates have optional or required '''parameters''' that change the output of the template, giving it more versatility.
When invoking a template with parameters, separate each parameter with a pipe symbol {{code|<nowiki>|</nowiki>}}.
* Template with one parameter:
** Code: {{code|<nowiki>{{enchantment|+1}}</nowiki>}}
** Result: {{enchantment|+1}}
* Template with multiple parameters:
** Code: {{code|<nowiki>{{AttributeBlock|8|15|7|6|10|8|hp=12|dex save = yes|race=Bird|hp=10}}</nowiki>}}
** Result:
{{AttributeBlock|8|15|7|6|10|8|hp=12|dex save = yes|race=Bird|hp=10}}
==== Template documentation ====
{{hatnote|See also: [[Help: Template documentation]]}}
Template creators are encouraged to document (on the template's page itself as well as via the TemplateData button on the same page) how to use that template, including usage examples and accepted values for any template parameters. If you're unfamiliar with a particular template, navigate to its page to learn how it works. If a template page does not show any usage instructions, it could still be a work in progress, and you may want to check with its creator before using it.
See [https://bg3.wiki/wiki/Special:AllPages?namespace=10 All Pages (Template namespace)] for a full list of available templates on bg3.wiki.
==== More template examples ====
* The {{code|<nowiki>{{DamageInfo}}</nowiki>}} and {{code|<nowiki>{{DamageText}}</nowiki>}} templates can insert pre-formatted damage information based on the parameters you provide, like so:
**{{code|<nowiki>{{DamageInfo|2d6+1|Slashing|modifier=melee}}</nowiki>}} displays {{DamageInfo|2d6+1|Slashing|modifier=melee}}
**{{code|<nowiki>{{DamageText|1d4|Fire}}</nowiki>}} displays {{DamageText|1d4|Fire}}, better for compact or inline usage
* The {{code|<nowiki>{{Icon}}</nowiki>}} and {{code|<nowiki>{{SmallIcon}}</nowiki>}} templates help you add an icon to represent a spell or item, like so:
** {{code|<nowiki>{{Icon|Chain Mail Icon.png}} [[Chain Mail]]</nowiki>}} displays {{Icon|Chain Mail Icon.png}} [[Chain Mail]], the better alternative to this is [[Template:ItemIcon]].
** {{code|<nowiki>{{SmallIcon|Magic Missile Icon.png}} [[Magic Missile]]</nowiki>}} displays {{SmallIcon|Magic Missile Icon.png}} [[Magic Missile]], the better alternative to this is [[Template:SAI]].


== Additional resources ==
== Additional resources ==
8,856
edits

Navigation menu