Help:Class: Difference between revisions

1,700 bytes added ,  1 November 2024
Line 181: Line 181:
==== Use full wikitext instead of #template_display ====
==== Use full wikitext instead of #template_display ====
You need to manually write out how you want template data to appear using MediaWiki's language, rather than relying on the automated or semi-automated display mechanisms provided by extensions like Cargo. This approach is chosen for greater control, customization, or when the display logic provided by extensions does not meet the specific needs or design requirements of the page.
You need to manually write out how you want template data to appear using MediaWiki's language, rather than relying on the automated or semi-automated display mechanisms provided by extensions like Cargo. This approach is chosen for greater control, customization, or when the display logic provided by extensions does not meet the specific needs or design requirements of the page.
Example Setup:
Create a Template: Let's say you have a template named ExampleTemplate that you want to use for displaying data from a Cargo table called ExampleTable.
Template Code (Template:ExampleTemplate):
mediawiki
<div class="example-box">
<h2>{{{name|}}}</h2>
<p><strong>Description:</strong> {{{description|No description provided}}}</p>
<p><strong>Year:</strong> {{{year|Unknown}}}</p>
</div>
Cargo Query with Full Wikitext:
Wiki Code:
sql
<nowiki>{{#cargo_query:
|tables=ExampleTable
|fields=name, description, year
|format=template
|template=ExampleTemplate
|use full wikitext=true
}}</nowiki>
By setting use full wikitext=true, the template parser will interpret all wikitext within the template, allowing for more complex layouts, headings, classes, etc., as defined in your template.
Explanation:
ExampleTable: This is your Cargo table containing fields like name, description, and year.
ExampleTemplate: This template formats how each row from ExampleTable will be displayed.
<nowiki>{{{name|}}}</nowiki> means it will display the name field, with an empty string if name is not provided.
<nowiki>{{{description|No description provided}}}</nowiki> shows the description or a default message if none exists.
<nowiki>{{{year|Unknown}}}</nowiki> similarly handles the year.
Query Parameters:
* format=template specifies that we're using a template for output.
* template=ExampleTemplate tells Cargo which template to use.
* use full wikitext=true enables the full wikitext interpretation within the template.
This method allows for richer, more customized display options directly from your Cargo query results, integrating seamlessly with MediaWiki's text processing capabilities.


The options are:
The options are:
CargoAdmin, Bureaucrats, Moderators (CommentStreams), fileuploaders, newuser
401

edits