Jump to content

Help:Class: Difference between revisions

3,165 bytes added ,  2 November 2024
→‎Sections: highlight
(→‎Sections: highlight)
 
(5 intermediate revisions by 2 users not shown)
Line 108: Line 108:
===Output format===
===Output format===
The options are:
The options are:
Each of these formats can be customized further by using parameters like template, named args, or separator to control how data is displayed or separated within the result. Remember that the exact syntax and capabilities might depend on the version of Cargo you are using, so always check the latest documentation for the most current options and features.


==== Table ====
==== Table ====
* The table is the default output format for Cargo queries.
* Results are displayed in a tabular format with each row representing a record and columns for each field of the record.
Example:
<syntaxhighlight lang="python">{{#cargo_query:
|tables=ExampleTable
|fields=Field1, Field2
}}
</syntaxhighlight>
==== Side Infobox ====
* Side [[infobox]] is designed for displaying information in a box typically positioned to the side of an article.
* This format creates a box that can be floated to the right or left of content, useful for displaying metadata or summary information about a subject.
Example:
<syntaxhighlight lang="python">{{#cargo_query:
|tables=ExampleTable
|fields=Field1, Field2
|format=infobox
}}</syntaxhighlight>
==== Plain Text ====
* Use this when you need the output in plain text, without any HTML formatting.
* This format removes all HTML tags and presents data in a straightforward text manner, which can be useful for embedding data in text or for custom formatting.


* This is the default output format for Cargo queries.
==== Sections ====
* Results are displayed in a tabular format with each row representing a record and columns for each field of the record.
* Sections are useful when you want to organize information into sections within a page.
* Each record is displayed as a section, often with a header. This format is handy for creating detailed pages where each section represents different aspects or entries of a subject.


Example{{#cargo_query: |tables=ExampleTable |fields=Field1, Field2 }}
Example:
*
<syntaxhighlight lang="python">{{#cargo_query:
*Side [[infobox]]  - This...
|tables=ExampleTable
*Plain text - This...
|fields=Field1, Field2
*Sections - This...
|format=sections
}}</syntaxhighlight>


===Options===
===Options===
Line 153: 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: