Extension talk:CategoryLink


 * v1.5 Archive

Archive
I archived discussion relating to the older version Kyle van der Meer 16:42, 10 February 2010 (UTC)

Forked code (refactored, more configurable)
Hi Kyle, thanks for this extension. I needed to fork it for my purposes and thought you and your users might find it usefull. All I did is that I threw out dependecy on external CSS, cleaned the main cycle and added few variables for strings. Use it as you wish. My changed printcategorylinks function looks like this: function printcategorylinks { /* begin config */ $columns = 3;//change this number to the number of columns you want. $html_list_begin = "\n\t\t".' '; $html_line_begin = "\n\t\t\t".' '; $html_line_end = "\n\t\t\t".' '; $html_cell_begin = "\n\t\t\t\t".''; $html_cell_end = ' '; $html_emptycell_placeholder = " ";

/* end config */

global $wgDBuser,$wgDBpassword, $wgDBname,$wgDBserver,$IP, $wgDBprefix; $link = mysql_connect($wgDBserver, $wgDBuser, $wgDBpassword) or die('Could not connect: ' . mysql_error); mysql_select_db($wgDBname) or die('Could not select database'); $query = 'SELECT DISTINCT cl_to FROM '.$wgDBprefix.'categorylinks'; $result = mysql_query($query) or die('Query failed: ' . mysql_error); $cell_count = 0; $output = $html_list_begin; $output .= $html_line_begin; while($row = mysql_fetch_row($result)) { $category_code = $row[0]; $category_name = preg_replace("/_/"," ",$row[0]);

$output .= $html_cell_begin."\n\t\t\t\t".''.$category_name."".$html_cell_end; $cell_count++; if($cell_count%$columns==0) $output .= $html_line_end.$html_line_begin; }

for($i=($columns - $cell_count%$columns)%$columns; $i>0; $i--) $output .= $html_cell_begin. $html_emptycell_placeholder. $html_cell_end;

$output .= $html_line_end; $output .= $html_list_end;

return (.$output.); }