Discuss $smwgNamespacesWithSemanticLinks
Not returning properties and/or categories in custom namespaces
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.
Help? Aerrin99 (talk) 16:54, 9 April 2013 (UTC)
- 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 [[kgh]] (talk) 10:41, 20 April 2013 (UTC)- 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? Aerrin99 (talk) 16:38, 30 April 2013 (UTC)
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. Aerrin99 (talk) 18:43, 30 April 2013 (UTC)
- Try setting
$smwgNamespaceIndex. Alexander Mashintalk 20:10, 30 April 2013 (UTC)
- Try setting
Already done (see original post) and set to 100 as such:
$smwgNamespaceIndex = 100;
Sorry, I should have clarified - I grabbed that example off the extension page. Mine is actually set to 500 to avoid that problem.
Wikilog::setupNamespace( 500, 'Blog', 'Blog_talk' );
Though it may be possible that it's conflicting with something else I have installed. Is there a way to check? Aerrin99 (talk) 21:34, 2 May 2013 (UTC)
- Check, whether by the time you set
$smwgNamespacesWithSemanticLinks[NS_BLOG] = true;NS_BLOGis defined. This implies thatWikilog::setupNamespace( 500, 'Blog', 'Blog_talk' );has already been invoked. - You can call
$wgDebugComments = true; wfDebug ('NS_BLOG = ' . NS_BLOG);to check the value of the constant. - You can also use
{{NAMESPACENUMBER:(full page name)}}parser function to check the number of any namespace in the wiki. Alexander Mashintalk 10:14, 3 May 2013 (UTC)- Check, whether by the time you set $smwgNamespacesWithSemanticLinks[NS_BLOG] = true; NS_BLOG is defined. This implies that Wikilog::setupNamespace( 500, 'Blog', 'Blog_talk' ); has already been invoked.
- It is, yes.
- You can call $wgDebugComments = true; wfDebug ('NS_BLOG = ' . NS_BLOG); to check the value of the constant.
- Not quite sure what I'm doing with this - shove them both in LocalSettings? Doing so gets me a new error: Fatal error: Call to undefined function wfDebug() in /home/xmm/public_html/w/LocalSettings.php on line 223 Aerrin99 (talk) 19:28, 3 May 2013 (UTC)
- Did you find the solution? I have the same problem, although with different defintion of namespaces. See my latest post about this issue (saw this post right after that..).
- Thanks! Ontzettend (talk) 20:35, 30 August 2013 (UTC)
- Check, whether by the time you set
It looks to me like this should be a very simple fix, if I'm reading things right...
First of all, you should switch to using defined constants instead of magic numbers:
## Define namespaces
define( "NS_BLOG", 500 );
...as kgh recommended. Of course, you could just use the magic number 500 in both places, but it's better to use a defined constant to prevent mistakes.
Then register your namespace using the wikilog extension using your defined constant instead of the magic number "500":
Wikilog::setupNamespace(NS_BLOG, 'Blog', 'Blog_talk' );
...i.e., that's the same as writing $wgExtraNamespaces[NS_BLOG] = "Blog"; to declare the new namespace, except it also does some additional setup related to the Wikilog extension, and ensures you declare the namespace correctly.
Now your namespace is set up, set it to allow semantic properties by adding
$smwgNamespacesWithSemanticLinks[NS_BLOG] = true;
...hope that helps. Verbatim9 (talk) 19:52, 14 April 2014 (UTC)
- I tried a large number of things until I figured out that I was making my smwgNamespacesWithSemanticLinks declarations *before* the enableSemantics call. When I moved them after it (as described in the documentation, although only briefly), everything started working great. Bjp (talk) 01:16, 22 May 2014 (UTC)
Talk Namespace with semantic links
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? Oleander Hans (talk) Oleander Hans (talk) 11:15, 30 March 2015 (UTC)
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. [[kgh]] (talk) 14:31, 30 March 2015 (UTC)
- 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. Oleander Hans (talk) 10:59, 31 March 2015 (UTC)
- That was written long ago, when properties belonged to the pages' subjects, not the pages themselves; and a talk page has no subject. Now than several special properties like Modification date are introduced, this is not the case. Alexander Mashintalk 01:51, 31 March 2015 (UTC)
The status of NS_PROPRTY
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. Ahmad (talk) 14:51, 29 September 2018 (UTC)
- > 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?
- [0] 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.
- [0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/src/NamespaceManager.php#L203-L217 James Hong Kong (talk) 03:25, 30 September 2018 (UTC)
Can't activate smw on custom namespace
Summary: Mediawiki namespace definition must set before invoking Semantic MediaWiki.
Hi,
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.
Any ideas?
My configuration is the following
MediaWiki 1.31.1
PHP 7.0.32-0ubuntu0.16.04.1 (apache2handler)
MySQL 5.7.24-0ubuntu0.16.04.1
ICU 55.1
Elasticsearch 5.6.1
Lua 5.1.5
SMW 3.0
Thanks for any help! Lorenzo Loman87 (talk) 09:24, 7 December 2018 (UTC)
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
Suggested clarification
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. Ahmad (talk) 15:54, 7 February 2019 (UTC)