I've seen it done in the past, but I can't remember or find how.
I've seen it done in the past, but I can't remember or find how.
Do you want to add a category to a sub-page of a template?
No - Add Category To Article/File Page From /doc Sub-template
Place category on /doc page (ie. Template:Example/doc) -> Template:Example/doc is transcluded onto Template:Example -> Template:Example is transcluded onto an article/file page, along with category placed on Template:Example/doc (the article/file page is the only one of these three pages added to the category).
You only want to add a category to Template:Example/doc, without that this category will jump automatically to Template:Example.
Maybe try something like this:
{{#ifeq:{{NAMESPACE}}|Template||[[Category:Category]]}}
{{#ifeq:{{NAMESPACE}}|Template||[[Category:Category]]}}
Just realized that {{Documentation}} isn't transcluded with the template so this (or any other options) can't work. I guess a limitation to the current, less efficient method of documentation practices/abilities.
I'm confused as to why you'd want this behaviour in the first place. To me, it just seems natural to categorize the article page from the template itself, which also leads to cleaner code. I also tend to categorize the template from the /doc page, mostly to prevent the template from categorizing itself in the article category.
(Wow, that paragraph is a mess, isn't it? LOL ... Perhaps the examples below will be more clear.)
Template, option 1:
code, code, code, more code, more code <includeonly>[[Category:Article cat]]</includeonly><noinclude> {{documentation}}</noinclude>
Template, option 2:
<includeonly>code, code, code, more code, more code [[Category:Article cat]]</includeonly><noinclude> {{documentation}}</noinclude>
/doc:
doc text, doc text, more doc text <includeonly>[[Category:Template cat]]</includeonly><noinclude> [[Category:Template documentation]]</noinclude>
Hope that helps. :-)
Hope that helps. :-)
I'm someone who would like to have all categories (applying to /doc, template, and article) in one place and this request was one out of the spur of the moment. As noted in my last post, it's currently no possible (which I overlooked when I posted this thread, I was thinking of a different use of tags that's not relevant here). While I appreciate you trying to help, your examples just aren't appropriate for this thread (or are repetitive as my second post above shows).
As for your last statement, you are stating you are placing a category on the /doc page that could apply to articles, which isn't possible. For the template to be categorizing itself in the article category, the article category needs to be on the /doc page or you missused/not using the correct tags on the template page. You can have the code for an article and a template category on the template page without applying the category to the template or article respectively (as is usually done on wikis that don't use documentation pages).
Repetitive, perhaps. More like clarification, from my point of view.
Completely don't understand why the examples are not relevant, but don't wish to argue or debate the matter, either.
DEmersonJMFM wrote:
As for your last statement, you are stating you are placing a category on the /doc page that could apply to articlesOnly if I stated the reverse of everything I intended! LOL ... Our wiki has several templates where the documentation includes "live" examples, in which case the template page becomes the includeonly page. It therefore gains the categories intended for the article pages, since the template page is standing in for an article page. I've been correcting these as I find them by adding category suppression code, usually by allowing categorization only in mainspace. Eventually, I'd like to remove the "live" examples altogether.
I'm someone who would like to have all categories (applying to /doc, template, and article) in one place
That's the heart of the matter, really--the programmer's preference. It's a shame the software won't accommodate your preference. :'(
I've seen this, but it's easy enough to fix with a simple parser function. Live examples are quite useful for people who don't quite understand how templates work and need to see first hand how the syntax provided displays the template so I'd recommend keeping them.
DEmersonJMFM wrote:
Live examples are quite useful for people who don't quite understand how templates work and need to see first hand how the syntax provided displays the template so I'd recommend keeping them.
Good point. I'll just keep writing suppression code, then. ;-)