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!

Add Comment

Details

* Comment:

Anti-SPAM


CAPTCHA Image

Submit

Log Comment?
("Log Comment" can only apply to those who have an account here at ; if you do, make sure you use the same Name and E-Mail your account uses.)

Twitter Feed »

  • New Blog Post: Listing Admin: Important Bugfix: http://ow.ly/2pWwa August 15th, 2010
  • New Blog Post: Call for Beta Testers (and a Tiny-Little-Note)!: http://ow.ly/25sVx June 30th, 2010
  • New Blog Post: Listing Admin 2.2: http://ow.ly/1XJSd June 12th, 2010