Extension talk:Hierarchy

Unofficial Version 1.2.0
I am Mark (User:Cowtung). I have posted an unofficial version 1.2.0 here: Extension:Hierarchy/Hierarchy1.2.0.php. I added a root parameter to the tag. This will remove whatever prefix you specify from all links generated. I needed this for my wiki, and decided to share.

Here is the new create table code. If you already have this table, you can just add the RootText and Deslash columns to that. If you drop the table and run this to create it again, you'll have to go through and save all your index pages again.

To set the root param for the index...

I also...
 * 1) Added "deslash" param which tells the extension to remove all but the last element in forward slashed article hierarchies ("Some_Book:Book_Title/chapter1/subitem1/subitem2" -> "subitem2") for all links.
 * 2) Removed all trailing and leading carriage returns and hr tags.
 * 3) Added in the breadcrumbs (thanks to the guy who posted that).
 * 4) Reformatted some of the code to meet the standards of my company (no if statements without braces, etc.).

Removing carriage returns helps you format things exactly the way you want. I use this as my Template:Hierarchy_footer...

This is the footer of a page that belongs to a hierarchy.

I didn't know where or how to post this unofficial version, and I didn't want to bother with creating a new extension. If anybody has any suggestions, I'll do my best to implement them. Thanks for a great extension which I hope I haven't damaged too much. :)

Also, I'm not sure how well this works without the root tag. This code definitely could use some cleanup.

Instructions about templates
I wanted to mention to you that it would be more clear in your instructions on the mediawiki site if you named the 'Template:Hierarchy header' 'Hierarchy header' because in your examples, you call , not. Anyone messing around with this stuff should understand what transclusions are but I thought I would let you know the inconsistencies.

Is there any site where this extension can be seen in action?
No, sorry. But you can install it on a test site and follow the usage sample to try it out. --Fernando Correia 15:42, 1 February 2007 (UTC)

Do you think this extension will work on MW 1.6.7?
Regards, Aretai 11:04, 5 February 2007 (UTC)


 * Well, it might. But I cannot verify that. My focus is to support the newest version. Only one way to find out... --Fernando Correia 11:31, 5 February 2007 (UTC)

OK have had a try. Some minor problems with: CREATE TABLE `mywikidb`.`hierarchy` ( `Id` int( 10 ) unsigned NOT NULL AUTO_INCREMENT,  `IndexArticleId` int( 10 ) unsigned NOT NULL ,  `TocLevel` int( 10 ) unsigned NOT NULL ,  `TocNumber` varchar( 255 ) NOT NULL ,  `TocText` varchar( 255 ) NOT NULL ,  `Sequence` int( 10 ) unsigned NOT NULL ,  `ArticleId` int( 10 ) unsigned NOT NULL ,  `PreviousArticleId` int( 10 ) unsigned NOT NULL ,  `NextArticleId` int( 10 ) unsigned NOT NULL ,  `ParentArticleId` int( 10 ) unsigned NOT NULL ,  PRIMARY KEY ( `Id` ) ,  KEY `IndexArticle` USING BTREE( `IndexArticleId` , `Sequence` ), KEY `ArticleId` ( `ArticleId` ) ) ENGINE = MYISAM DEFAULT CHARSET = latin1;

Got an error 1064 - think some problems with KEY? What version of MySQL does your extension support? Aretai 14:41, 8 February 2007 (UTC)


 * MySQL version 5. Take a look, you have to replace `mywikidb` for the name of your database. --Fernando Correia 15:35, 8 February 2007 (UTC)

Yes I know:) I've already replaced it. Well will try again, however probably just need to update my software Aretai 09:45, 9 February 2007 (UTC)


 * Probably this error is more related to MySQL than to MediaWiki. If at all possible try to update PHP, MySQL and MediaWiki. --Fernando Correia 10:40, 9 February 2007 (UTC)

Id did have this Error 1064 on MySQL - 4.0.18, too. It appears to work when you avoid "USING BTREE". I hope this has no side effects (appart from performance ones). --Francesc Hervada-Sala, 217.95.231.1 08:44, 28 May 2007 (UTC)

I cannot install the extension properly
Thank you for this extension, I think it will be very useful to me. After copying all files and configuring the LocalSettings.php as indicated, I get this warning at every page of my wiki: Warning: Cannot modify header information - headers already sent by (output started at .../extensions/Hierarchy.php:2) in .../includes/WebResponse.php on line 10 Does anyone know how to fix it? I use MediaWiki 1.10.0 --Francesc Hervada-Sala, 217.95.231.1 08:44, 28 May 2007 (UTC)

I had the same error, following the instructions with Mediawiki 1.10.0. MAW

I also have this error for several extensions. Can anyone provide a solution? MW 1.11.

Try to save it without Unicod Signature (BOM) for example with Notepad2...

Getting error after setup
Enabling produces the following error: Warning: Missing argument 2 for wfHierarchyParserFunction_Magic in extensions/Hierarchy.php on line 381

This line in the code from the wiki is: function wfHierarchyParserFunction_Magic( &$magicWords, $langCode ) { # Add the magic word # The first array element is case sensitivity, in this case it is not case sensitive # All remaining elements are synonyms for our parser function $magicWords['hierarchy-top'] = array( 0, 'hierarchy-top' ); $magicWords['hierarchy-bottom'] = array( 0, 'hierarchy-bottom' ); # unless we return true, other parser functions extensions won't get loaded. return true; }

Can you let me know what the workaround might be?

Is it possible to include (the first N levels of) the hierarchy in the sidebar?
--wimh 13:49, 8 May 2007 (UTC)

previous and next buttons [images]
the previous and next text works fine, but the arrows are merely images. as a textbook over caffeinated netizen, i usually aim for the largest thing that i can click on to get me where i am going, in this case the arrow, but alas, it is only an image.

is there a way to make the images links as well? basically back and forward buttons is what i am looking to do.

Zeefreak 16:38, 23 April 2008 (UTC)

Must charset be latin1?
The last line in the code that creates the MySQL table is:

ENGINE = MYISAM DEFAULT CHARSET = latin1;

Could I substitute UTF-8 without harm?

Is there anyone willing to update this extension so it will work in MW 1.16.0/PHP 5.3.3?
After installing the extension, I get the following error:

Detected bug in an extension! Hook fnHierarchySaveHook failed to return a value; should return true to continue hook processing or false to abort.

If anyone knows a fix for this or can update the extension, it'd be greatly appreciated. Unfortunately I don't have the necessary PHP skills or I'd do it myself.

Kwelsh2 20:04, 15 February 2011 (UTC)

Allow less than 4 items
It would be nice to remove the limitation of at least 4 items in the index. This may lead to confusion when users try to build the index incrementally. Probably a _TOC_ used internally in the index function could do it. --Fernando Correia 13:24, 9 March 2007 (UTC)

Subordinate pages in the navigation box (resolved)
Great extension! It works fine for me. However, it would be great to have the subordinate pages listed in the navigation box as well, instead of them only being displayed in the footer. 130.83.196.179 16:44, 6 March 2007 (UTC)


 * Thanks for the feedback. I agree that this would be a good idea. Probably showing as an indented bulleted list. There could be an option to have these pages on the footer, in the box, or both. --Fernando Correia 18:39, 6 March 2007 (UTC)

I have hacked the extension so as to include subordinate pages in the navigation box, can send you the modified file if you are interested. 130.83.196.179 14:36, 7 March 2007 (UTC)


 * Sure, please do! You can post it here or email it to me. --Fernando Correia 16:58, 7 March 2007 (UTC)


 * Thank you for your contribution, Felix! Version 1.1.0 is released. --Fernando Correia 17:01, 8 March 2007 (UTC)

Alternate text in index
Nice extension which helps me a lot. One thing I'm missing is to use another text in the index than the link, something like Piped Links. When using ... &lt;index&gt; [[ Top Page ]

Sample Chapter
... I get a link to Sample_Chapter, instead of Chapter1

Tried also this form a (b) but this gives an error in $page_url = $title->escapeLocalURL; Thanks for your help. --Daniel 11:26, 9 March 2007 (UTC)


 * I agree. I've already had this need also. I think this can be allowed with a little tweaking in the parser. This form should be easy to allow: == Sample Chapter == --Fernando Correia 11:11, 9 March 2007 (UTC)

That was fast! You think you might adopt this? Knowing this, I could already start using this form in my pages. Thanks --Daniel 12:25, 9 March 2007 (UTC)


 * Talk about fast. By the timestamps, it seems I'm answering them before you ask them! :-)


 * I'd definitely like to have this feature. Maybe I can take some time to take a look at it today. No promises, though. In the meantime you can create a page redirect to have an alternate name. --Fernando Correia 12:20, 9 March 2007 (U

Also wanted to add a "me too" - this would be VERY helpful. Any rough idea on timeframe when you think you might have this added? THANK AGAIN- Jon

Auto Header/Footer
Is it possible to have each new page created on my wiki to have the Hierarchy Header and Hierarchy Footer includes (i.e. with the brackets) automatically put on each new page. In this way all that I'd have to do is add it to the index. BTW: Great extension - it's a HUGE help to me- thanks! Jon

Classic breadcrumbs
A classic breadcrumb path, based on item hierarchy, can be easily achieved with the following additions to the extension source code:

Having done this little coding, it takes just a template definition and insertion to start using breadcrumbs. The one-time step template definition (Template:Hierarchy breadcrumb or something like it) could be::

This is the breadcrumb of a page that belongs to a hierarchy.

While for each page that will belong to the hierarchy, in which we want the breadcrumb to be displayed will be something like:

This is a page that belongs to a hierarchy.

Of course, the code can be improved in order to parametrize some aspects of behaviour and/or appereance. That is why I have included this little contribution here (in feature requests), so that the author may adapt or modify it as he considers to be the best way (sorry for my far-from-perfect english).

--Metagrama 11:42, 6 August 2008 (UTC)

Transclude Child Pages for an Index Item
It would be nice if we had a way to optionally transclude all child pages for a given index item in only one page. This would be great because some users want to see all the information on the same page instead of navigating teh index structure to see all the items.

What do you think?

- Gabriel (glajman AT gmail DOT com) - March 11, 2009

Table prefixes
It seems the extension does not work when table prefixes are used. --Fernando Correia 18:47, 4 April 2007 (UTC)


 * I haven't seen any problems using this extension and table prefixes so far (only tested on a very limited demo site), off course the CREATE TABLE statement should be altered so that the hierarchy-table has the same prefix as the other tables --wimh 13:46, 8 May 2007 (UTC)

Mediawiki 1.10
This extension is great, but it screws up the layout on Mediawiki 1.10. The Writing is huge, and there are spaces between many elements, e.g. between The page and the tabs at the top, or around the logo. --91.3.112.102 12:05, 29 May 2007 (UTC) (Die_Backe)

edit: I checked the html-code of the mainpage with and without the extension installed. Only commentarys (processing time, caching of the page) and pagefiews are different. And there is a space in the very first line. ("< !DOCTYPE" with, "<!DOCTYPE" without extension). Any idea? -- Die_Backe, 91.3.112.102 12:14, 29 May 2007 (UTC)

Blank page when user login
When a user logs in to our wiki the page is blank. When you are not logged in you can see the index page. One of my users had this problem on her machine but I could log in on my machine with her login and see the index. Now, today, I can't see the index page with her log in or my own sysops loggin. I don't know if this because of the prefixes on the table or not. It seems more like a cache issue because of how intermittant the viewing has been over the last few days.

Does anyone have any ideas? Thanks, Margaret

Back again, I think I figured out my issue. I protected the index page so no one but a sysop could edit the page and in return, it doesn't show the outline when a user is logged in. I hope this solution fixes this back and forth behavior.

Index fails with large index
I have a large index (about 700 pages). The index fails at about 600 pages. After messing around with the code I found the problem at the find TOC pattern: $pattern = '@ Is there any way to hide the Book: namespace by just adding a variable? It's not so bad in the index, but on the individual pages it can get a bit long. --Greg 05:43, 12 April 2008 (UTC)

Same page in multiple indcies
One more thing... can you have pages that you want to use in multiple hierarchies? What is the best way to do this? Should you create a template that has the data and then pull that into the page? I take it the hierarchy can not tell how you got to that page... Just a thought. Thanks for this extension. It's EXACTLY what I wanted.

--Greg 05:51, 12 April 2008 (UTC)

Hierachy table tags are not XHTML Compliant
The .php file generates non compliant XHTML table tag. As shipped the script generates a width attribute of width="200px" rather than width="200" (note 200 is arbitary) See line 477 in .php source. --84.92.164.19 12:38, 10 November 2008 (UTC)