Difference between revisions of "List-Cat.php"
From Organic Design wiki
(This should fix the space/underscore problem) |
(No ODRER BY in cat SELECT) |
||
Line 8: | Line 8: | ||
$cat = str_replace(' ', '_', $cat); | $cat = str_replace(' ', '_', $cat); | ||
$article = trim($article)."\n"; | $article = trim($article)."\n"; | ||
− | $result = $db->query("SELECT cl_from,cl_sortkey FROM $cl WHERE cl_to = '$cat'"); | + | $result = $db->query("SELECT cl_from,cl_sortkey FROM $cl WHERE cl_to = '$cat' ORDER BY cl_sortkey"); |
while ($row = mysql_fetch_assoc($result)) { | while ($row = mysql_fetch_assoc($result)) { | ||
$id = $row['cl_from']; | $id = $row['cl_from']; |
Revision as of 11:17, 24 January 2006
<?
- Append article content with a list of article-names from category specified in properties
$db =& wfGetDB( DB_MASTER ); $subdb =& wfGetDB( DB_SLAVE ); $cl = $db->tableName('categorylinks'); $cur = $db->tableName('cur'); xwGetProperty($properties, 'list-cat', $cat); $cat = str_replace(' ', '_', $cat); $article = trim($article)."\n"; $result = $db->query("SELECT cl_from,cl_sortkey FROM $cl WHERE cl_to = '$cat' ORDER BY cl_sortkey"); while ($row = mysql_fetch_assoc($result)) { $id = $row['cl_from']; $subresult = $subdb->query("SELECT cur_title FROM $cur WHERE cur_id=$id"); if ($subrow = mysql_fetch_assoc($subresult)) { $title = str_replace('_', ' ', $subrow['cur_title']); $anchor = str_replace('_', ' ', $row['cl_sortkey']); $anchor = ($title != $anchor) ? "|$anchor" : ; $article .= "*$title$anchor\n"; } } ?>