Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 05-30-2008, 08:20 PM
warmonger Offline
forum loafer
 
Join Date: May 2008
Posts: 6
No More Empty Categories

This change would be cool to apply to future versions of PP. When creating categories, you may create photo categories that you have no photos for (call it future planning). Currently, PP shows ALL categories in the drop down box when browsing, regardless if you have no photos associated with each category. Make the following change to the "functions_browse.php" page and it will correct this issue.

On line 109 where it reads this:

Code:
$query = mysql_query("SELECT * FROM ".$pixelpost_db_prefix."categories ORDER BY name");
Change to this:

Code:
$query = mysql_query("SELECT DISTINCT C1.id, C1.name, C1.alt_name FROM " .$pixelpost_db_prefix. "categories C1 INNER JOIN " .$pixelpost_db_prefix. "catassoc C2 ON C2.cat_id = C1.id ORDER BY C1.name");
From here on out, you can create all the categories you like, but they will only show up, once you've assigned a photo to a category.

Enjoy,

Ken
Reply With Quote
  #2  
Old 06-02-2008, 01:35 AM
witty's Avatar
witty Offline
pp veteran
 
Join Date: Mar 2007
Posts: 72
Hi,

Sounds like a smart, clean idea to me.


-Witty
__________________
Reply With Quote
  #3  
Old 06-02-2008, 10:26 AM
eversonl Offline
forum loafer
 
Join Date: May 2008
Posts: 8
Hi, this does sound good.. but I made the change and my empty cat still show up in browse

edit: ah, it's because I use darkmatter temlpate which has its own function for displaying categories.
Darkmatter users who want to use this should edit dm_support.php line 216

from
Code:
$cquery = mysql_query('select * from ' .$pixelpost_db_prefix . 'categories order by name asc');
to
Code:
$cquery = mysql_query("SELECT DISTINCT C1.id, C1.name, C1.alt_name FROM " .$pixelpost_db_prefix. "categories C1 INNER JOIN " .$pixelpost_db_prefix. "catassoc C2 ON C2.cat_id = C1.id ORDER BY C1.name asc");
Reply With Quote
  #4  
Old 06-04-2008, 09:14 PM
warmonger Offline
forum loafer
 
Join Date: May 2008
Posts: 6
I noticed the same thing was happening when I switched over the the paged_archive addon. The same change (in my original post above) can be applied to line 570 in the paged_archive.php page.

Change:
Code:
$query = mysql_query("SELECT * FROM ".$pixelpost_db_prefix."categories ORDER BY name");
to this:
Code:
$query = mysql_query("SELECT DISTINCT C1.id, C1.name, C1.alt_name FROM " .$pixelpost_db_prefix. "categories C1 INNER JOIN " .$pixelpost_db_prefix. "catassoc C2 ON C2.cat_id = C1.id ORDER BY C1.name");
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 08:39 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs