Extension talk:SubPageList2

There is a bug in the following function:

function options( $options ) with the namespace option extraction.

A fix for the bug in question could be:

if( isset( $options['namespace'] ) ) {     if( is_numeric( $options['namespace'] ) ) $this->namespace = intval($options['namespace']); else if( is_string( $options['namespace'] ) ) {       	if( $this->language->getNsIndex( $options['namespace'] ) !== false ) $this->namespace = $this->language->getNsIndex( $options['namespace'] ); else $this->error( "Using not defined namespace." ); } 		else $this->error( "Unknown value for option namespace." ); }

Europäische Union
Im ZUM-Wiki habe ich eine Liste von Unterseiten für die Seite Europäische Union angelegt:
 * http://www.zum.de/wiki/index.php/Europ%C3%A4ische_Union#Unterseiten

Der Quelltext: 

Das Ergebnis: * Europäische Union * Ratspräsidentschaft der BRD * Verfassungsentwurf der EU

Wie kann die Anzeige verbessert werden? --Karl.Kirst 21:00, 7 January 2007 (UTC)

Auf der verlinkten Seite im ZUM-Wiki scheint inzwischen keine SubPageList mehr verwendet zu werden. Das beschriebene Problem tritt jedoch auch bei mir auf: Als erster Punkt in der Liste der Unterseiten taucht immer der Titel der aktuellen Seite auf (Mediawiki 1.6.8, das Wiki ist nicht öffentlich, daher leider kein Link). --195.226.123.200 07:53, 12 January 2007 (UTC)


 * SubPageList2 dürfte euch helfen. Das Beispiel müsste nun so aussehen:


 * --Schaelle 19:16, 28 March 2007 (UTC)

deepness (argument)?
Shouldn't that rather be "depth"?!
 * Hm, I'm german. It can. Feel free to change, its OpenSource and I'm no more developing the extension. --Schaelle 19:13, 28 March 2007 (UTC)

Exploration - what works and what doesn't, and beware of NESTING!

 * From http://lists.wikimedia.org/pipermail/mediawiki-l/2007-July/021532.html
 * > Earlier: if I have a page A, and I create a
 * > subpage, A/B/C, but A/B does not exist, 
 * > then A/B/C will automatically link back to
 * > A, but not A/B, since it doesn't exist. 
 * > > Yes. 
 * > The question is, what happens if I now
 * > create A/B after A/B/C is already
 * > created. Will the wiki recognize that
 * > A/B/C is a subpage of A/B? 
 * > > Yes. 
 * > A/B/C is a subpage of A/B? 
 * > > Yes. 
 * > > Yes. 


 * From http://lists.wikimedia.org/pipermail/mediawiki-l/2007-July/021551.html
 * ''> > A search for "subpage" on MediaWiki.org returns,
 * ''> > among the top three hits,
 * http://www.mediawiki.org/wiki/Manual:%24wgNamespacesWithSubpages
 * http://www.mediawiki.org/wiki/Manual:LocalSettings.php#Enabling_subpages.
 * ''> > In the absence of a decent page explaining
 * ''> > it, I'll fill in, in brief, that when "subpages"
 * ''> > are enabled for a namespace, MediaWiki considers,
 * ''> > e.g. "Page/Subpage" in a title to be more
 * ''> > meaningful; it will show little "breadcrumb"
 * ''> > navigation links at the top of the page.
 * ''> > Note that whether or not subpages are enabled,
 * ''> > one can find all titles matching a pattern,
 * ''> > e.g. "Page/*" using Special:Prefixindex.


 * (Note: > above = "DI", > > = "RC")

Peter Blaise asks:

--

Q1: you say that a subpage automatically *links* back to the page it's a sub of? What do you mean by *links*? I see no auto anything on my subpages or on the pages they are a subpage of (v1.10.0). Can you show an example of what "automatically *link* back" looks like?

A1: See second quote above! Thank you Rob.

--

Q2: And why would we do this? What tools in MediaWiki help us search, sort and select/display/print the data that is organized as subpages such as "a", "a/b", and "a/b/c"?

I just built these pages and a few more to experiment:


 * a
 * a/b
 * a/b/c
 * a/a
 * a/b/a
 * a/b/b
 * a/a/a/a
 * a/a/a/b
 * b
 * b/a
 * b/a/a
 * b/a/b
 * b/b
 * b/b/a
 * b/b/b
 * b/b/c

... and so on, for way more pages than I probably need (I have a lot of cleaning up to do after this test!). All the red links above for me in my own private wiki are actually live blue links to the articles and subpages.

On each "a" page I put the word "ardvark". On each "b" page I put the word "bayonette". On each "c" page I put the word "carlisle".

... and so on. These are words I knew were NOT in my wiki otherwise (hey, misspellings can be useful during testing).

Results:


 * - ALL these pages, including sub pages, show up in special:allpages.


 * - A [ search ] for ardvark, bayonette or carlisle finds ALL pages, including sub pages, that contain the words searched for.

I cannot divine a MediaWiki-native way to show ONLY pages below "a" or ONLY pages below "a/b" or any other limit or control of focus over where the search/sort/select looks. (v1.10.0)

--

Q3: Does anyone know of tools within MediaWiki (or extensions) that provide such a result? I thought someone mentioned that subpages automatically get a listing in or to the article/page they are an subpage of, but that's not happening (v1.10.0)

As far as I can tell, a value for me of a subpage is to allow me to have otherwise identically named subpages under different articles with otherwise different contents, like this list of article/pages keeping track of, say, computer resources:


 * Computer1
 * Computer1/hardware-inventory
 * Computer1/service-history
 * Computer1/software-inventory
 * Computer1/user-list
 * Computer2
 * Computer2/hardware-inventory
 * Computer2/service-history
 * Computer2/software-inventory
 * Computer2/user-list
 * Computer3
 * Computer3/hardware-inventory
 * Computer3/service-history
 * Computer3/software-inventory
 * Computer3/user-list

--

Q4: how would I list all pages ONLY under Computer1, for instance? (Read on, I found an answer.)

A4: I found this extension:


 * http://www.mediawiki.org/wiki/Extension:SubPageList2

... and found it's php file here:


 * http://stuff.schaelle.de/SubPageList2/SubPageList2.zip

... and put it's php file here:


 * ..\extensions\subPage2.php

... and added the following lines using a text editor to ..\LocalSettings.php

require_once("extensions/SubPageList2.php");
 * 1) for SubPageList extension

Then I confirmed by using Special:Version and saw:

Subpage List 2 Martin Schallnahs, Rob Church

Thanks, Martin and Rob! Then, after printing and reading the "documentation" and casting out much that failed to work as described, I found that THIS worked when typed in as the text contents of a page that has subpages:

< subpages deepness=1 / >

And then I see THIS as it's contents when rendered (from my expanded a/b/c example above), for example, let's add those lines to page "a" - then it shows this:


 * A
 * ardvark
 * A/a
 * A/a/a/a
 * A/a/a/a/z
 * A/a/a/b
 * A/b
 * A/b/a
 * A/b/b
 * A/b/c
 * A/z
 * A/b/c
 * A/z

... again, all the red links above for me in my own private wiki are actually live blue links to the subpages. THIS feature I can use as a benefit to show a clickable table of contents list of all subpages under, say, Computer1. GREAT!

--

Q5: How would I list all "*/hardware-inventory" pages only?

A5: I could create a category and categorize them, then the special page [category:Service-history] will display a clickable table of contents, and the fact that they are all subpages is irrelevant:


 * Articles in category "Service-history"
 * There are 3 articles in this category.
 * C
 * Computer1/service-history
 * Computer2/service-history
 * Computer3/service-history
 * Computer1/service-history
 * Computer2/service-history
 * Computer3/service-history

Good. Unless, I also have a < subpages/ > command IN the "Computer1" article page, which I want to do. Then, the < subpages/ > command bets interpreted first, ad MediaWiki thinks the "computer1" page also is in the [category:service-history] page:


 * Articles in category "Service-history"
 * There are 6 articles in this category.
 * C
 * Computer1
 * Computer1/service-history
 * Computer2
 * Computer2/service-history
 * Computer3
 * Computer3/service-history
 * Computer2/service-history
 * Computer3
 * Computer3/service-history

Lesson? Plan my nesting carefully, and maybe learn to modify and enhance the extension to make it more disciplined.

Now, oddly enough, it seems that the "subpages" extension is smarter in a dumb way in that I just tried a sample article/page called "z" and added to it's text contents merely < subpages / > and got a list of ONLY other pages at the same level (immediately "under" the main namespace) which happen to also have "z" in their titles - anywhere within the title! But no subpages! Cool. This feature could make a strange indexer or sorts.

But when I type THIS into the text of *any* page:

< subpages parent=a / >

I get this:


 * A/a/a/a
 * A/a/a/a/z
 * A/a/a/b
 * B/a/a

Not "all children of any 'a' page" as I expected, but sort of, "only all *terminus* pages whose *immediate* parent is an 'a' page". Weird. I was expecting "all sub pages of any 'a' parent", which SHOULD have yielded:


 * A
 * A/a
 * A/a/a
 * A/a/a/a
 * A/a/a/a/z
 * A/a/a/b
 * B/a/a

THIS odd behavior is why I've been so often frustrated when trying to follow directions but have gotten different results than the original programmer got in their environment - change ONE thing and all logic falls away! =8 ^ o

--

Q6: How to get the list above, "all subpages of any parent named 'a'", on demand?

I also tried simplifying using the "showpath=no" argument:

< subpages parent=a showpath=no / >

But that just returns:


 * a
 * z
 * b
 * a

Which is which? So, "showpath=no" seems a tough option to find value for in my examples.

So, as hinted to above in the category exploration, the funny thing about the < subpages / > command is, if they are called or nested, the < subpages / > command seems to get interpreted/parsed as if it was on the calling page, not on the page where it sits. For example, on page "a/b" containing only the text < subpages / >, when I open the page directly, it shows a list as expected with only itself and it's own subpages, like this:


 * A/b
 * ardvark bayonette
 * A/b
 * A/b/a
 * A/b/b
 * A/b/c
 * A/b/b
 * A/b/c

Yet, when this "a/b" page gets called, nested, found, referred to, and or included in another article/page's list, then it gets interpreted/parsed as if it were resting in/on the CALLING page, no longer as if it were on it's own original the "a/b" page. Argh! Example, if on page "a" I put something like:

< subpages deepness=1 / >

I get a list of subpages under the current "a" page":


 * A
 * ardvark
 * A/a
 * A/a/a/a
 * A/a/a/b
 * A/b
 * A/b/a
 * A/b/b
 * A/b/c
 * A/z
 * A/b/c
 * A/z

BUT, if in page "a" I add the preview feature:

< subpages deepness=1 mode=preview / >

It shows the contest of each subpage, but when it shows the contents of the subpage "a/b" in the list, the "a/b" call for showing < subpages / > suddenly shows all subpages of the entire "main namespace" equal in level to the calling "a" page, not to the original source of just the subpages of "a/b"!

So, I must be careful not to nest the subpage extension command else it will behave differently when nested than it does when it's not nested.

Thanks for exploring.

-- Peter Blaise peterblaise 16:51, 6 July 2007 (UTC)

PS - Why don't category links show up as red when they don't exist? I would expect to render like this:   rather than disappear altogether! I guess because they expect categories to render at the bottom of the page only after editing is done, they "disappear" form the preview display during editing. Quirky!