Last modified: 2006-04-15 14:51:16 UTC
Templates used in an article sometimes want to refer to the associated talk page. Templates used om a talk page sometimes want to refer to the associated non-talk page. It's impossible for template designers to do this correctly without making unportable assumptions. To refer to the talk page, a template could use something like [[Talk: {{PAGENAME}}]], but that fails if the target should really have been [[Wikipedia talk:{{PAGENAME}}]] or [[Template talk:Pagename]], etc. It could use [[{{NAMESPACE}} talk:{{Pagename}}]], and this probably works for all namespaces in the English wikipedia, but not in other languages. To refer to the non-talk page from a talk page, a template could use [[{{PAGENAME}}]], but this works only in the main namespace. See [[en: Template:Todo]] and [[en:Template:WikipediaTodo]] for a pair of templates that are identical except for having to work around this problem. New variables that allowed us to say [[{{NAMESPACE_TALK}}:{{PAGENAME}}]] and [[NAMESPACE_NO_TALK}}:{{PAGENAME}}]] would be helpful, and should be easy to implement. NAMESPACE_TALK would have to get the namespace as a numeric value, then set least significant bit (via something like "$ns |= 1;"), and convert the result from a numeric to a string namespace. NAMESPACE_NO_TALK would be much the same, except it would clear the least significant bit (via something like "$ns &= ~1;").
(In reply to comment #0) > Templates used in an article sometimes want to refer to the associated > talk page. Templates used om a talk page sometimes want to refer to the > associated non-talk page. It's impossible for template designers to do > this correctly without making unportable assumptions. Templates that need to refer to the talk page, and are used in more than one namespace, seem pretty rare. For every page, the sidebar already has a link to the associated talk or non-talk page, which should reduce the need for another link. > To refer to the talk page, a template could use something like [[Talk: > {{PAGENAME}}]], but that fails if the target should really have been > [[Wikipedia talk:{{PAGENAME}}]] or [[Template talk:Pagename]], etc. It > could use [[{{NAMESPACE}} talk:{{Pagename}}]], and this probably works > for all namespaces in the English wikipedia, but not in other languages. Why not?
(In reply to comment #1) > (In reply to comment #0) > > could use [[{{NAMESPACE}} talk:{{Pagename}}]], and this probably works > > for all namespaces in the English wikipedia, but not in other languages. > > Why not? I know I replied to this months ago, but my reply doesn't appear. Weird. Proof by example should be good enough: In finnish, the equivalent of "Talk" is "Keskustelu", the equivalent of "Template" is "Template", but the equivalent of "Template talk" is "Template talk", not "Template keskustelu". Also, the finnish equivalent of "Wikipedia" is "Wikipedia", but the equivalent of "Wikipedia talk" is "Keskustelu Wikipediasta", not "Wikipedia keskustelu" or "Wikipedia talk".
You don't need any new variables. This can be defined with the software as is. How to do it: First: create a normal template: {{NAMESPACE_TALK}} Then define the template as: {{namespace_talk_for_{{NAMESPACE}}}} Next, is the tricky part. I would recommend going to the talk page for the NAMESPACE_TALK, and putting the following in it: {{namespace_talk_for_}} {{namespace_talk_for_{{subst:ns:1}}}} {{namespace_talk_for_{{subst:ns:2}}}} {{namespace_talk_for_{{subst:ns:3}}}} {{namespace_talk_for_{{subst:ns:4}}}} {{namespace_talk_for_{{subst:ns:5}}}} {{namespace_talk_for_{{subst:ns:6}}}} {{namespace_talk_for_{{subst:ns:7}}}} {{namespace_talk_for_{{subst:ns:8}}}} {{namespace_talk_for_{{subst:ns:9}}}} {{namespace_talk_for_{{subst:ns:10}}}} {{namespace_talk_for_{{subst:ns:11}}}} {{namespace_talk_for_{{subst:ns:12}}}} {{namespace_talk_for_{{subst:ns:13}}}} {{namespace_talk_for_{{subst:ns:14}}}} {{namespace_talk_for_{{subst:ns:15}}}} Once you have saved that, then you can define each of the 16 templates. For example: {{namespace_talk_for_}} should be defined to be Talk, and {{namespace_talk_for_Talk}} should be defined to be Talk, and {{namespace_talk_for_User}} should be defined to be User_talk, and so on and so forth. Then, when the template {{NAMESPACE_TALK}} is expanded in the main namespace, it will expand to {{namespace_talk_for_}} which will expand to Talk, but when {{NAMESPACE_TALK}} is expanded in the User namespace, it will expand to {{namespace_talk_for_User}} which will expand to User_talk. So, now you can do things like: [[{{NAMESPACE_TALK}}:{{PAGENAME}}]] and it will work (as long as you properly defined all the sub namespace variables). The only signifcant advantage of doing it as a real variable are that you save defining a bunch of template variables (34 to be exact, per wikimedia installation), and it automatically works for all the wikipedias.
(In reply to comment #3) > So, now you can do things like: [[{{NAMESPACE_TALK}}:{{PAGENAME}}]] Linking works perfectly with this workaround, however nesting does not. Take for example the {{TODO}}-template: Todo-lists should be saved as sub-entries in the discussion namespace, so that there only can be a unique todo-list for each entry. I want to import the items of the todo-list using {{{{NAMESPACE_TALK}:{{PAGENAME}}/to_do}} which evaluates to {{{{NAMESPACE_TALK}:Pagename/to_do}} instead of =================================== * Create NAMESPACE_TALK variable * Create NAMESPACE_NO_TALK variable * Item 3 to do ===================================
Created attachment 412 [details] added variables simply added the variables NAMESPACE_TALK and NAMESPACE_NO_TALK to includes/Parser.php includes/MagicWords.php languages/Language.php
Halló! I tried to rebuild [[en:Template:To do]] at http://jadesukka.homelinux.org:8180/betawiki/Malline:Task At [[en:Template:To do]] I identified the following problems: - it does not use inline links for the "Image" and "Category" namespaces - it place the "to do" pages in the NAMESPACE_NO_TALK namespace; this generates errors in the image namespace and makes no sense for category namespace; acces to the special namespace is limited anyway - it references only to the NAMESPACE_NO_TALK page either from NAMESPACE_NO_TALK or NAMESPACE_TALK but does not reference "from outside" i.e. from another namespaces or pages It was a hard job to implement a version which: - emulates an extension <inline> ... </inline> for this particular case, - use an "alternate table" to define the location of the "to do" pages which is mainly required tor image, category, special but also for (main) and Mediawiki namespaces - allows to share the content from different locations - creates an alternative body to display the image for the image namespace - is "portable" to other languages (up to the point where "localurl" fails using non 7 bit charavtes in parameters) - provides a priority managment feature and a category management to handle a great amount of "to do pages" Please do not ask about the amount of objects to emulate the required IF ELSIF ELSE END or CASE ... statements or doubling parameters because of the lack of an <underscores> ... </underscores> extension. The lack of variables as NAMESPACE_TALK or NAMESPACE_NO_TALK or GENERICNAMESPACE or many other required features does NOT prevent from being less MediaWiki safe. It only makes the development of new applications more painfull and more complex. I was surprised about the new resptrictions encountered with "localurl" which I did not expect. I suggest that it should be improuved / fixed with common efforts. Best regards Reinhardt ]] user:gangleri [[
I find this very useful, and it would only take 5 minutes for someone to add it to CVS! In 1.5rc4, I changed Parser.php and Language.php the same as in the diff file (although manually). Since new constants have been added to MagicWord.php, I had to change the two constant values in MagicWord.php, and the position in the file. I also added them to $wgVariableIDs, although I don't know what that's for.
{{TALKSPACE}} and {{SUBJECTSPACE}} have been checked into SVN. Should this bug be closed?
just a note for interested people, please look up SVN to see what was added exactly: http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/MagicWord.php?view=log#rev13612 Thanks Rob \o/