Difference between revisions of "List-Cat.php"
From Organic Design wiki
(newline problem) |
(Had to modify to handle sort-keys) |
||
| Line 1: | Line 1: | ||
<? | <? | ||
# Append article content with a list of article-names from category specified in properties | # Append article content with a list of article-names from category specified in properties | ||
| − | $db =& wfGetDB( DB_SLAVE ); | + | $db =& wfGetDB( DB_MASTER ); |
| − | $cl = $db->tableName( 'categorylinks' ); | + | $subdb =& wfGetDB( DB_SLAVE ); |
| − | xwGetProperty( $properties, 'list-cat', $cat ); | + | $cl = $db->tableName('categorylinks'); |
| − | $article = trim( $article )."\n"; | + | $cur = $db->tableName('cur'); |
| − | $result = $db->query( "SELECT cl_sortkey FROM $cl WHERE cl_to = '$cat'" ); | + | xwGetProperty($properties, 'list-cat', $cat); |
| − | while ( $row = mysql_fetch_assoc($result) ) | + | $article = trim($article)."\n"; |
| − | $ | + | $result = $db->query("SELECT cl_from,cl_sortkey FROM $cl WHERE cl_to = '$cat'"); |
| + | 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"; | ||
| + | } | ||
| + | } | ||
?> | ?> | ||
Revision as of 06:04, 15 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); $article = trim($article)."\n"; $result = $db->query("SELECT cl_from,cl_sortkey FROM $cl WHERE cl_to = '$cat'"); 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"; } } ?>



