Last modified: 2011-03-13 18:05:40 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T25297, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 23297 - Getting [[SMW::on]] in query result set when used in Mediwiki:Sidebar
Getting [[SMW::on]] in query result set when used in Mediwiki:Sidebar
Status: RESOLVED WONTFIX
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Lowest minor (vote)
: ---
Assigned To: Markus Krötzsch
:
: 23212 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-23 14:17 UTC by Neill Mitchell
Modified: 2011-03-13 18:05 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Neill Mitchell 2010-04-23 14:17:24 UTC
I want the sections of my website automatically appear in my MW sidebar as they are created by a SMW form.

So in http://localhost/mediawiki/index.php/Mediawiki:Sidebar I have:

* navigation
** mainpage|mainpage-description
** portal-url|portal
** currentevents-url|currentevents
** recentchanges-url|recentchanges
** randompage-url|randompage
** helppage|help
{{#ask:
[[Category:Sections]]
[[Title::+]]
|?Section Link#-
|link=none
|format=template
|template=Sidebar Query
}}

The Sidebar Query Template is:

** {{{1}}}|{{{2}}}

The result is that I get the section names and their links appearing in the sidebar as expected, except for one problem. The last one has [[SMW::on]] after it. e.g.:

Section1
Section2
Section3
Section4[[SMW::on]]

The [[SMW::on]] should not be showing. Where is it coming from? 

Posted on SMW mailing list but got no answer.

Thanks
Neill
Comment 1 Markus Krötzsch 2010-05-23 18:13:34 UTC
SMW::on is an internal pseudo-annotation that SMW uses to avoid semantic markup in templates being interpreted when using templates in queries.

The problem here is that MediaWiki does not interpret link syntax [[ ... ]] in MediaWiki:Sidebar. Now on the other hand, this is not really a problem: the parsing of complex markup in such heavily used locations is disabled on purpose. I am even surprised that parser functions and templates are allowed there.

Your problem thus is simply due to an unexpected use of SMW in a context it is not made for. You will find that many #ask formats, and many other parser functions do not work properly in MediaWiki:Sidebar. This is a consequence of some design choices in MediaWiki, and not a bug as such. It simply was intentionally disabled.

Since this use of MW or SMW is not intended, it is likely to cause unforeseen problems or to break in future versions, even if worked around for now. But if you *really* want to do this, the following works:

* Create a new Type:String property, say "sidebar item".
* For each page that should appear in the sidebar, assign the value 

 "* Pagename|Sectionname" 

to this property. Due to the | symbol, this cannot be done with the [[ :: ]] syntax. Instead, use #set like this:

  {{#set: sidebar item=* Pagename{{!}}Sectionname}}

where the Template:! is the usual | template like on Wikipedia. This assignment could be accomplished via some template.

* Then modify your MediaWiki:Sidebar to contain something like this:

"""

* Some section name
** help|A fixed help link
** Test|Some other fixed link
{{#ask: [[Sidebar item::+]]
|mainlabel=-
|intro=*
|?sidebar item=
|link=none
|format=list
|sep=
*
}}

"""

This works for me on MW 1.17alpha (r63248), SMW (r66801).

Let me repeat: this is a gross hack that is likely to cause trouble of various kinds. If it works properly, any editor of your site gains the ability to modify the sidebar in arbitrary ways (to the extent that editing MediaWiki:Sidebar would allow it). It is also not clear how the use of queries in messages affects performance or how it interacts with in-memory caches used for messages.

This is all that I can do for this feature request.
Comment 2 Markus Krötzsch 2010-05-23 18:16:32 UTC
*** Bug 23212 has been marked as a duplicate of this bug. ***
Comment 3 Neill Mitchell 2010-05-24 09:10:52 UTC
Hi.

Thanks very much for the information. I have found a non hacky way to do this :)
You put the following in LocalSettings.php:

$wgHooks['MonoBookTemplateToolboxEnd'][] = 'wfNavTree';
function wfNavTree() {
        global $wgUser, $wgTitle, $wgParser;
        if ( is_object( $wgParser ) ) $psr =& $wgParser; else $psr = new Parser;
        $opt = ParserOptions::newFromUser( $wgUser );
        $nav = new Article( Title::newFromText( 'NavTree', NS_MEDIAWIKI ) );
        $out = $psr->parse( $nav->fetchContent( 0, false, false ), $wgTitle, $opt, true, true );
        echo '</ul></div>' . $out->getText();
        return true;
}

You can then have a normal page called "NavTree" (in this example) with any markup in you like. This includes SMW queries. They then appear in the sidebar.

So I do not think it will be a good use of your valuable time to implement a hack in SMW.

Many thanks
Neill.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links