[Mediawiki-l] Subpages with missing ancestors

Monahon, Peter B. Peter.Monahon at USPTO.GOV
Fri Jul 6 15:37:19 UTC 2007


> 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.

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?

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!).  

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

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

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

... where all the "- " lines shown above are actually live blue links to
the subpages.  THIS I can use 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

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]]:

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

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 

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

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, "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 than expected when it's not nested.

Thanks for exploring.

-- Peter Blaise




More information about the MediaWiki-l mailing list