Template:Section category

From WhyNotWiki

Jump to: navigation, search


Contents

[edit] Syntax

{{section category
|category_title
|text
}}
  1. category_title: if is the exact text "plural", will assume text is in singular form and will use texts (plural form) as category name (this is useful because categories are so often plural)
  2. text (optional): if omitted, makes a link to the article named category_title


[edit] Introduction

The original use for this was to work around the problem that categories can only apply to entire pages/articles, not to sections of the page (unless you actually pull those sections out into their own pages and transclude them!).

This was accomplished by transcluding this template (passing in the category name) instead of just making a link to the category like one normal would.

So we do this:

{{section category|Language}}

instead of this:

[[Category:Language]]

This has two useful effects:

  • It adds the entire page to that category (which the [[Category:Language]] method does for you anyway)
  • It inserts the category name as text

Two for the price of one!

This can be used in the body of the section—even right in the middle of a sentence—or in the section heading. Example:

=={{section category|Language}}==


[edit] Examples

[edit] Simple case

[Caveats (category)]

[edit] Automatic pluralization of category

Needed as a result of: Having an article title with a different number than its associated category.

This is a big {{section category|plural|caveat}}.

This is a big [caveat (category)].

This works most of the time, thanks to most English nouns following the simple rule that adding -s makes it plural. But if you have a word that doesn't follow that rule, see the next section...

Keep in mind, however, that just because you want the text to be singular and the category plural does not mean you want the text to be a link to a singular article...

For example, this may be a singular "caveat", but there may still be an article called "Caveats" ... in which case you should not use this "plural" feature ... To be completely correct and complete, you'd have to do it like this:

This is a big {{section category|Caveats|[[Caveats|caveat]]}}. Yuck.

Maybe there's never a good time to use it. Maybe this just needlessly complicates things. I'm not sure.

See Having an article title with a different number than its associated category


[edit] Custom pluralization or if you don't want an article link to be created

Use this form if you need to have a different case for the article than for the category

It is an {{section category|Attribute languages|[[Attribute language]]}}

It is an [Attribute language (category)]

Or if you want the text to not be a link (by default it is a link):

It is an {{section category|Attribute languages|Attribute language}}

It is an [Attribute language (category)]

See also: Template:Link with category (may want to merge eventually)


[edit] Removing redundant scope

On the page Rails plugins and libraries / Development tools, it is already obvious that everything on the page is Rails-related (that is, we inherit that context from the page's topic). So it would be redundant to specify "Rails / Testing":

{{section category|Rails / Testing}}

Instead, we shorten it to just Testing:

{{section category|Rails / Testing|Testing}}

This is optional, however. Do it if you think it will make things look good but it's not a requirement.

Someday maybe it will be done for you automatically.

[edit] .

See also: Template:Keyword


Category templates  edit   (Category  edit)


Link templates  edit   (Category  edit)


Section templates  edit   (Category  edit)


Personal tools