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?
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.
Try setting $smwgNamespaceIndex
.
Already done (see original post) and set to 100 as such:
$smwgNamespaceIndex = 100;
You cannot set two different extensions to the same namespace ID. That's what you are just doing.
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?
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.
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.
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
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!
I never did! Eventually sort of gave up, though I pop in occasionally to see if anything new has come up. I'll keep an eye on your post!
Sorry to not have better news.
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.