Difference between revisions of "List-Cat.php"

From Organic Design wiki
(let's do some cat-listing on OD :-))
 
(Change to plain list (no columns))
Line 1: Line 1:
 
<?
 
<?
# Append article content with items from category specified in properties - 2005-10-10
+
# Append article content with a list of article-names from category specified in properties
$db =& wfGetDB(DB_SLAVE);
+
$db =& wfGetDB( DB_SLAVE );
$cl = $db->tableName('categorylinks');
+
$cl = $db->tableName( 'categorylinks' );
xwGetProperty($properties, 'list-cat', $cat);
+
xwGetProperty( $properties, 'list-cat', $cat );
$result = $db->query("SELECT cl_sortkey FROM $cl WHERE cl_to = '$cat'");
+
$result = $db->query( "SELECT cl_sortkey FROM $cl WHERE cl_to = '$cat'" );
$items = array();
+
while ( $row = mysql_fetch_assoc($result) )
$i = 0;
+
$article .= "*[[".str_replace('_', ' ', $row['cl_sortkey'])."]]\n";
while ($row = mysql_fetch_assoc($result)) $items[++$i%3][] = $row['cl_sortkey'];
 
$article .= "\n<table><tr>";
 
foreach ($items as $row) {
 
$article .= "<td valign=top>\n";
 
foreach ($row as $i) $article .= "*[[".str_replace('_', ' ', $i)."]]\n";
 
}
 
$article .= "</table>\n";
 
 
?>
 
?>

Revision as of 07:03, 14 January 2006

<?

  1. Append article content with a list of article-names from category specified in properties

$db =& wfGetDB( DB_SLAVE ); $cl = $db->tableName( 'categorylinks' ); xwGetProperty( $properties, 'list-cat', $cat ); $result = $db->query( "SELECT cl_sortkey FROM $cl WHERE cl_to = '$cat'" ); while ( $row = mysql_fetch_assoc($result) ) $article .= "*[[".str_replace('_', ' ', $row['cl_sortkey'])."]]\n"; ?>