Pixelpost Forum

Pixelpost Forum (http://www.pixelpost.org/forum/index.php)
-   Hacks and Modifications (http://www.pixelpost.org/forum/forumdisplay.php?f=16)
-   -   No More Empty Categories (http://www.pixelpost.org/forum/showthread.php?t=8490)

warmonger 05-30-2008 08:20 PM

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

witty 06-02-2008 01:35 AM

Hi,

Sounds like a smart, clean idea to me.


-Witty

eversonl 06-02-2008 10:26 AM

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");

warmonger 06-04-2008 09:14 PM

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");


All times are GMT. The time now is 08:06 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.