I often use subpages in my wiki. Therefor the subpages shall be edited by clicking [edit]. This works for pages with enough headings but not for pages without them.. I also know solutions, using a template like "edit subpage". But the next problem the [edit]-buttons are hidden and the [edit-subpage] buttons are still visible when a user is not logged in.
So i'm looking for a php-solution when using the {{:subpage}} syntax.
Any ideas?
Thanks Heinz
On 19/09/05, topi topologis@t-online.de wrote:
I often use subpages in my wiki. Therefor the subpages shall be edited by clicking [edit]. This works for pages with enough headings but not for pages without them.. I also know solutions, using a template like "edit subpage". But the next problem the [edit]-buttons are hidden and the [edit-subpage] buttons are still visible when a user is not logged in.
So i'm looking for a php-solution when using the {{:subpage}} syntax.
Er, I was a little confused at first as to what you were trying to do - which if I understand rightly has nothing to do with what are commonly called subpages (things like [[Talk:Foo/Archive 1]]). What I *think* you're asking is: how can you have an automatic "edit" button next to every included *template* (or in the case of {{:subpage}}, a page from the Main namespace being included as a template).
I've seen this suggested before, but it was pointed out that many templates are very small, aren't necessarily designed to be visibly separate from the rest of the page, and generally vary too much for an automated way of placing the links.
However, if they're used in a fairly uniform way on your wiki, you could hack the part of Parser.php which deals with template inclusions to add text to the page its including - somewhere in the braceSubstitution() function, perhaps.
Another alternative might be to write an extension (see http://meta.wikimedia.org/wiki/Write_your_own_MediaWiki_extension) which displays an edit link if the user is logged in, and nothing otherwise; or one which displays its input if logged in, and nothing otherwise, which you can then put inside a template. A simple version might be something like this (from memory and what other people have put on meta):
--------------------------- $wgExtensionFunctions[] = "registerLoggedInOnly";
function registerLoggedInOnly() { global $wgParser; $wgParser->setHook( "ifloggedin", "loggedInOnlyCallback"); }
function loggedInOnlyCallback($input, $args) { global $wgUser; if ( ! $wgUser->isLoggedIn() ) { return ""; # do nothing for logged out users } else { global $wgUser, $wgTitle; $parserOptions = ParserOptions::newFromUser( $wgUser ); $parser = & new Parser(); return $parser->parse($input, $wgTitle, $parserOptions); } } ---------------------------
You could then create a template at "Template:Editlink" like: <ifloggedin><small>[{{SERVER}}{{localurl:{{{1}}}|action=edit}} (edit)]</small></ifloggedin>
And use it in your other template pages like: {{editlink|name of template}}
A more advanced version might try and work out what the name of the template was automatically, but that's kind of complicated, because variables like {{PAGENAME}} get set to the page being *viewed*, not the one containing the text, and I can't think off the top of my head how to get hold of the latter...
Oh, and I've just realised you *might* have problems with caching, but you might not, because logged in versus logged out is already a distinction in the caching I think...
wikitech-l@lists.wikimedia.org