Topic on Project:Support desk

[RESOLVED] Preloader will only preload the main boilerplate no matter what I set

5
Iamabigwikinoob (talkcontribs)

Preloader won't preload into any of my custom namespace.
In LocalSettings.php, I added this before $wgSitename:
// define namespace constants
define("NS_SPREADSHEET", 150); // This MUST be even.
define("NS_SPREADSHEET_TALK", 151); // This MUST be the following odd integer.
define("NS_CAT", 152); // This MUST be even.
define("NS_CAT_TALK", 153); // This MUST be the following odd integer.
define("NS_DOG", 154); // This MUST be even.
define("NS_DOG_TALK", 155); // This MUST be the following odd integer.

// add namespaces
$wgContentNamespaces[NS_SPREADSHEET] = "Spreadsheet";
$wgContentNamespaces[NS_SPREADSHEET_TALK] = "Spreadsheet_talk";
$wgContentNamespaces[NS_CAT] = "Cat";
$wgContentNamespaces[NS_CAT_TALK] = "Cat_talk";
$wgContentNamespaces[NS_DOG] = "Dog";
$wgContentNamespaces[NS_DOG_TALK] = "Dog_talk";

Then, I called preloader like this, right before the closing php tag:

require_once "$IP/extensions/Preloader/Preloader.php";
$wgPreloaderSource[NS_MAIN] = 'Template:Boilerplate';
$wgPreloaderSource[NS_SPREADSHEET] = 'Template:Boilerplatespreadsheet';
$wgPreloaderSource[NS_CAT] = 'Template:Boilerplatecat';
$wgPreloaderSource[NS_DOG] = 'Template:Boilerplatedog';

I checked http://www.example.com/w/api.php?action=query&meta=siteinfo&siprop=namespaces, and all of my namespaces seem to be initializing properly, Dog, Cat, and Spreadsheet and their associated talk namespaces are all there, and pages created in those namespaces end up where they belong. However, when I go to create, say, Dog:Dog1,it seems to be preloading Template:Boilerplate instead of Template:Boilerplatedog. The same is true of the Cat namespace.

My Non-stock Extensions:

  • Semantic Mediawiki
  • Semantic Forms
  • MobileDetect
  • Preloader
  • WYSIWYG extension

Also, something seems to be wrong with your edit button here: It created a double post when I hit save, which may soon be a triple post. Is it possible to delete them?

This, that and the other (talkcontribs)

You're misusing $wgContentNamespaces. This is an array of booleans, so if you want to set a namespace as a "content namespace" (see the linked page for the meaning of this term), you would use a line like $wgContentNamespaces[NS_DOG] = true;.

To set the name of a namespace, use $wgExtraNamespaces: $wgExtraNamespaces[NS_DOG] = "Dog";.

Iamabigwikinoob (talkcontribs)

Ohhhh so I declare the namespaces with ExtraNamespaces then initialize them in an array of ContentNamespaces. Sorry, I'm more of a java guy. And PHP is just similar enough that it took me about 2 days to learn over java/javasript, but just different enough that old habits die hard. Such as only putting strings in an array if they're going to be used in the same loop. Not a hard and fast rule, java can put variables anywhere you want it to, just a habit that I think makes for better readability. Apparently PHP doesn't like that. Thanks :)

This, that and the other (talkcontribs)

So did you solve your problem?

Iamabigwikinoob (talkcontribs)

Well, you solved my problem. PHP is so similar to java its scary, it literally took me 2 days to learn the basics, the internal logic is that similar, but there are just enough things that are slightly different (get instead of call/ask, $ instead of string or bool) to throw you off. I followed the link to the manual page you gave me, and I didn't even need to read the whole thing, as soon as I saw the word "array," I was like "oooooohhhhh, now I know how this works." So yes, I guess this thread can be closed/archived. Also, thanks dude :).

Reply to "[RESOLVED] Preloader will only preload the main boilerplate no matter what I set"