Ninja Links: Showing Link Count Under Subcategories
This was actually requested by someone, and I decided to throw it out there, in case any users non-savvy in PHP would like this feature.
Code
Open functions.php, and depending on your browser resolution, head over to line 271. Right under the following line:
if ($subkey == "name") {
Add the following code underneath that:
$pull = $mysql->query("SELECT * FROM `" . $dbpref . "links` WHERE `category` = '$subcatid' AND `approved` = '1'");
$sublinkcount = @mysql_num_rows($pull);
Now, a few lines down, you'll encounter this line of code:
} else {
This is just ending the drop-down menu for the subcategories and starting the lists. We are now going to change the following line:
echo '<li><a href="links.php?cat='.$subcatid.'">'.$spacer.$info.'</a></li>'."\r\n";
To this line:
echo '<li><a href="links.php?cat='.$subcatid.'">'.$spacer.$info.'</a> (' . $sublinkcount . ' links)</li>'."\r\n";
Done! You now have the link count beside each subcategory! If you feel uncomfortable messing around with the coding, head over to the » downloads page and grab the file.
Extra: Sorting Links by Subject
If you would like the links sorted by subject (from A-Z), instead of by date, around line 292 (line 294 if you used the above mod), change the following line:
$buildQuery .= " ORDER BY `dateadded` DESC";
To this:
$buildQuery .= " ORDER BY `linkname` ASC";
Done! If you'd like your links from Z-A, change ASC to DESC.
Comments
Currently no comments!