Discuss Configuration parameter "$smwgNamespacesWithSemanticLinks"
|Thread title||Replies||Last modified|
|Suggested clarification||1||22:35, 8 February 2019|
|Can't activate smw on custom namespace||2||08:45, 10 December 2018|
|The status of NS_PROPRTY||1||04:25, 30 September 2018|
|Talk Namespace with semantic links||3||11:59, 31 March 2015|
|Not returning properties and/or categories in custom namespaces||14||02:16, 22 May 2014|
Perhaps it should be clarified in the documentation that even though the namespace "Property" is not among those for which $smwgNamespacesWithSemanticLinks is set by default, this doesn't affect the ability to use Property pages and annotate them with special properties, as these are part of the SMW system.
Last edit: 15:43, 7 December 2018
I have created a 'Bibliography' namespace, using the usual Mediawiki procedure. This is what I added in LocalSettings.php:
define("NS_BIBLIOGRAPHY", 3000); define("NS_BIBLIOGRAPHY_TALK", 3001); $wgExtraNamespaces[NS_BIBLIOGRAPHY] = "Bibliography"; $wgExtraNamespaces[NS_BIBLIOGRAPHY_TALK] = "Bibliography_talk";
The new namespace was successfully created. Then I activated smw on the new namespace, using:
$smwgNamespacesWithSemanticLinks[NS_BIBLIOGRAPHY] = true;
When I run the update script I have this php message
PHP Notice: Use of undefined constant NS_BIBLIOGRAPHY - assumed 'NS_BIBLIOGRAPHY' in /var/lib/mediawiki/LocalSettings.php on line 251
The line is that one of
$smwgNamespacesWithSemanticLinks, so I changed the NS_BIBLIOGRAPHY to 'NS_BIBLIOGRAPHY'. Anyway also after this change, smw doesn't work on the new namespace, even after rebuildData.php.
My configuration is the following
PHP 7.0.32-0ubuntu0.16.04.1 (apache2handler)
Thanks for any help! Lorenzo
As always I am somewhat amazed why people constantly fail to configure this. You are not alone here and I do not know why. Anyways here is how you do this and the order is imperative.
## Define custom namespaces // Must set before invoking Semantic MediaWiki define( 'NS_BIBLIOGRAPHY', 3000 ); define( 'NS_BIBLIOGRAPHY_TALK', 3001 ); ## Name custom namespaces // Must set before invoking Semantic MediaWiki $wgExtraNamespaces[NS_BIBLIOGRAPHY] = 'Bibliography'; $wgExtraNamespaces[NS_BIBLIOGRAPHY_TALK] = 'Bibliography_talk'; ## Semantic MediaWiki enableSemantics( www.example.com ); $smwgNamespacesWithSemanticLinks[NS_BIBLIOGRAPHY] = true; // Must set after invoking Semantic MediaWiki
The default list of domains for which
$smwgNamespacesWithSemanticLinks is set to true doesn't include the Property namespace, and indeed an example is given for the enabling of semantic annotation for pages therein.
However at the same time Property pages are annotated with special properties as part of their definition process. So does this mean that only special properties are enabled by default for property pages?
If so, then maybe this is worth stating.
> However at the same time Property pages are annotated with special properties as part of their definition process. So does this mean that only special properties are enabled by default for property pages?
 contains the default setting for namespaces defined by SMW which includes SMW_NS_PROPERTY therefore annotations work out of the box and are not limited to special properties.
I disagree with the statement "In fact, is is not obvious what a meaningful property of a talk page could be." For instance it could be used to tag proposals for enhancements of articles / wiki pages if it is not clear whether these changes should be committed to the page directly (the wiki way), e.g. because it currently does not comply with the site guidelines. -- Anyhow, I use a semantic "recently-change" #ask query in my SMW, and I would like to see Talk Pages on that list as well. However, even though NS_TALK is set to true both in the initial $GLOBALS['smwgNamespacesWithSemanticLinks'] array and in an extra
$wgNamespacesToBeSearchedDefault[NS_TALK] = true; statement (both are after the enableSemantics()-statement), the edit page keeps telling me I cannot use semantic annotations, and consequently the talk pages do not show up in my recently-changed-#ask-query. I start to wonder whether this works at all. Has anybody seen or get to work semantic annotations in SMW talk namespace? Hans Oleander (talk)
Well, if you look long enough for a meaningful reason you will find one. Reality has it that everything seems possible, so I will remove this sentence.
About your issue. I just tested on my test wiki by adding
$smwgNamespacesWithSemanticLinks[NS_TALK] = true;
enableSemantics call and indeed properties may now be set and they also pop up in my query results. Also the help message at the top tells me that I may now add annotations to the talk pages in main talk. There must be something else in the water at your end since I cannot confirm your findings.
It eventually turned out our admin had moved the wiki directory to a new location while leaving the old copy in place. Thus I was editing a localsettings.php to no effect... Sorry for the false alarm, and thank you for the (as always) kind and patient response.
I've been trying to get results across a number of namespaces and am at my wit's end.
What I've done:
- Set $smwgNamespaceIndex = 100; in LocalSettings.php BEFORE including SMW
- Edited my SMW_Settings.php to add
NS_BLOG => true, NS_FOO => true,
- Run the repair and upgrade options on Special:SMWAdmin.
The query reads:
It picks up both of those categories in the main namespace, as well as in other namespaces like User and Help, but will not pick up anything in Blog or Foo.
You have to enable your cusom namespace to also store semantic annotations, e.g. with
$smwgNamespacesWithSemanticLinks[NS_BLOG] = true;. Do this after you invoked the Semantic MediaWiki extension. Please never edit settings files but the LocalSettings.php file. Otherwise you are destined to run into trouble. Cheers
Doing that (after reverting my SMW_Settings.php) results in an error:
Notice: Use of undefined constant NS_BLOG - assumed 'NS_BLOG' in /home/xmm/public_html/w/LocalSettings.php on line 218 Warning: Cannot modify header information - headers already sent by (output started at /home/xmm/public_html/w/LocalSettings.php:218) in /home/xmm/public_html/w/includes/WebResponse.php on line 38 Warning: Cannot modify header information - headers already sent by (output started at /home/xmm/public_html/w/LocalSettings.php:218) in /home/xmm/public_html/w/includes/WebResponse.php on line 38
Any idea why?
Seems like you did something wrong with the definition of your namespace. See custom namespaces. Something like the following should be in your LocalSettings.php before the inclusion of extensions:
## Define namespaces define( "NS_BLOG", 1030 ); define( "NS_BLOG_TALK", 1031 ); ## Name namespaces $wgExtraNamespaces[NS_BLOG] = "Blog"; $wgExtraNamespaces[NS_BLOG_TALK] = "Blog_talk";
Thanks! I've tracked down the problem, I think - unfortunately not how to fix it.
The issue is that the namespaces in question are Wikilog namespaces. The extension requires me to use
Wikilog::setupNamespace( 100, 'Blog', 'Blog_talk' );
to set up the namespace. If I try it the proper way, the semantic asks work, but the wikilogs aren't wikilogs. If I try it the wikilog way, the semantic asks don't work.
I've tried moving things around to have wikilog define its namespaces before smw is included, but it doesn't seem to make a difference.