Not logged in
Talk
Contributions
Log in
Navigation
Main page
Recent changes
Random page
Upload file
Module
Discussion
Edit
View history
Editing
Module:Category handler/doc
(section)
From Body Communication
Jump to:
navigation
,
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!
=== 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 Body Communication are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (see
Body Communication:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, 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.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Tools
What links here
Related changes
Special pages
Page information