Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Cat: Difference between revisions

Template page
Content deleted Content added
// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>{{#ifexpr: 1 * {{#if: {{{name| }}} | {{#ifeq: {{{name}}} | {{PAGENAME}} | 1 | 0 }} }} * {{#if: {{{ns| }}} | {{#ifeq: {{{ns}}} | {{NAMESPACE}} | 1 | 0 }} }} | [[Category:{{{1}}}]] }}</includeonly><noinclude>
<includeonly>{{#ifexpr: (1 {{#if: {{{name| }}} | {{#ifeq: {{{name}}} | {{PAGENAME}} | * 1 | * 0 }} }}{{#if: {{{name| }}} | {{#ifeq: {{{name}}} | ''{{PAGENAME}}'' | + 1 | + 0 }} }}){{#if: {{{ns| }}} | {{#ifeq: {{{ns}}} | {{NAMESPACE}} | * 1 | * 0 }} }} | [[Category:{{{1}}}]] }}</includeonly><noinclude>
== Template Frontend ==
== Template Frontend ==
This template is used to categorize pages dynamically based on specific conditions. It evaluates the provided parameters and compares them to the current page name and namespace.
This template is used to categorize pages dynamically based on specific conditions. It evaluates the provided parameters and compares them to the current page name and namespace.

Latest revision as of 23:47, 8 February 2025

Template Frontend

This template is used to categorize pages dynamically based on specific conditions. It evaluates the provided parameters and compares them to the current page name and namespace.

Parameters

  • 1: str (required)
    The category name to assign to the current page if all conditions are met.
  • name: str (optional)
    If provided, this parameter specifies the page name to compare against the current page. If it matches the current page's name, the condition is satisfied.
    Defaults to an empty string if not provided, which means no name-based condition is applied.
  • ns: str (optional)
    If provided, this parameter specifies the namespace to compare against the current page's namespace. If it matches the current namespace, the condition is satisfied.
    Defaults to an empty string if not provided, which means no namespace-based condition is applied.

Additional Information

  • All conditions must evaluate to true for the category to be added. Specifically:
 * The name parameter must match the current page's name (if provided).
 * The ns parameter must match the current page's namespace (if provided).
  • If any condition fails, the category is not added to the page.

Template Backend

This template uses a combination of #if, #ifeq, and #ifexpr parser functions to check multiple conditions: 1. It checks if the name parameter matches the current page name. 2. It checks if the ns parameter matches the current namespace. 3. If all conditions are satisfied, it categorizes the page under the category specified by parameter 1.