Extension:ColList

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
ColList

Release status: Beta

Implementation Tag
Description A way to easily put a list of short items in columns (actually, a table).
Author(s) JulieC
Last version 1.1.0 (2007-12-13)
MediaWiki 1.9.3
License No license specified
Download Source Code at MindCapers
Example Example at MindCapers

Check usage (experimental)

ColList is an extension of MediaWiki which provides an easy way to put a lot of short items into columns. The items are give in a comma separated list. A working example, documentation and source code are located at mindcapers.com.

[edit] Category list display

To display your list in the same format as the category pages with the first letter capitalized, here is the code snippet to use in place of the table creation. This code snippit assumes that your list is already alphabetized. For short lists, the sort command could be added, but for long lists it will probably be too time consuming.

         $chunk = (int) (count ( $articles ) / 3);
 
                // get and display header
                $r = '<table width="100%"><tr valign="top">';
 
                $prev_start_char = 'none';
 
                // loop through the chunks
                for($startChunk = 0, $endChunk = $chunk, $chunkIndex = 0;
                        $chunkIndex < 3;
                        $chunkIndex++, $startChunk = $endChunk, $endChunk += $chunk + 1)
                {
                        $r .= "<td>\n";
                        $atColumnTop = true;
 
                        // output all articles in category
                        for ($index = $startChunk ;
                                $index < $endChunk && $index < count($articles);
                                $index++ )
                        {
                                // check for change of starting letter or begining of chunk
                                if ( ($index == $startChunk) ||
                                         (substr($articles[$index], 0, 1) != substr($articles[$index-1], 0, 1)) )
 
                                {
                                        if( $atColumnTop ) {
                                                $atColumnTop = false;
                                        } else {
                                                $r .= "</ul>\n";
                                        }
                                        $cont_msg = "";
                                        if ( substr($articles[$index], 1, 0) == $prev_start_char )
                                                $cont_msg = ' ' . wfMsgHtml( 'listingcontinuesabbrev' );
                                        $r .= "<h3>" . htmlspecialchars( substr($articles[$index], 1, 0) ) . "$cont_msg</h3>\n<ul>";
                                        $prev_start_char = substr($articles[$index], 1, 0);
                                }
 
                                $r .= "<li>{$articles[$index]}</li>";
                        }
                        if( !$atColumnTop ) {
                                $r .= "</ul>\n";
                        }
                        $r .= "</td>\n";
 
 
                }
                $r .= '</tr></table>';
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox