Home
Random
Recent changes
Special pages
Community portal
Preferences
About Real-Life Villains
Disclaimers
Real-Life Villains
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Category handler/doc
(section)
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!
=== The "page" parameter === For testing and demonstration purposes this module can take a parameter named '''page'''. Like this: <syntaxhighlight lang="lua"> p = {} local categoryHandler = require( 'Module:Category handler' ).main function p.main( frame ) local category = categoryHandler{ main = 'Category:Some cat', talk = 'Category:Talk cat', nocat = frame.args.nocat, -- So "nocat=true/false" works page = 'User talk:Example' } return category end return p </syntaxhighlight> In the above code we on purpose left out the brackets around the category names so we see the output on the page. No matter on what kind of page the code above is used it will return this: :{{#invoke:category handler|main | main = Category:Some cat | talk = Category:Talk cat | nocat = {{{nocat|}}} <!--So "nocat=true/false" works--> | page = User talk:Example }} The '''page''' parameter makes this module behave exactly as if on that page. Even the blacklist works. The pagename doesn't have to be an existing page. If the '''page''' parameter is empty or undefined, the name of the current page determines the result. You can make it so your module also understands the '''page''' parameter. That means you can test how your template will categorize on different pages, without having to actually edit those pages. Then do like this: <syntaxhighlight lang="lua"> p = {} local categoryHandler = require( 'Module:Category handler' ).main function p.main( frame ) local category = categoryHandler{ main = 'Category:Some cat', talk = 'Category:Talk cat', nocat = frame.args.nocat, -- So "nocat=true/false" works page = frame.args.page -- For testing } return category end return p </syntaxhighlight>
Summary:
Please note that all contributions to Real-Life Villains 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
Real-Life Villains:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)