Editing
Module:Categorization
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--<nowiki> local utils = require("Module:Utils") local p = {} --% This function is meant to be called with the names of the namespaces that pages can be categorized in. --% It returns a function to be used to categorize pages, which accepts any number of category names. function p.categorize_in_namespaces(...) local namespaces = {...} return function(...) local result = '' if mw.title.getCurrentTitle():inNamespaces(unpack(namespaces)) then for _, category in next, {...} do result = result .. "[[Category:" .. category .. "]]" end end return result end end --% This function can be called with any number of category names. --% If the current page is in a content namespace, it returns a string with links to each of the categories. Otherwise, it returns an empty string. --% The function is especially meant for templates that can be used on non-article pages, for example in the User namespace, and where such pages should not be added to article categories. function p.categorize_if_content_page(...) local result = "" if mw.title.getCurrentTitle().isContentPage then for _, category in next, {...} do result = result .. "[[Category:" .. category .. "]]" end end return result end --% This function is the same as the above but usable by {{#invoke:}}. --# TODO: Make it so that we can use one function instead function p._template_categorize_if_content_page(args) local categories = utils.trim_positional_arguments(args) local result = "" if mw.title.getCurrentTitle().isContentPage then for _, category in next, categories do result = result .. "[[Category:" .. category .. "]]" end end return result end p.template_categorize_if_content_page = utils.make_wrapper_function(p._template_categorize_if_content_page) return p
Summary:
Please note that all contributions to nUSA Wiki Archive may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
NUSA Wiki Archive:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Categorization/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Tools
What links here
Related changes
Special pages
Page information