INTRODUCTION The Pixelpost FAQ states that in order to use selected categories for the images on my main page, I should install the "GeoS Show Category" addon. I tried it, and while it looks to be a rather nice addon I wasn't happy with the fact that it mucked with my database. So, I looked at how the archive/browse code worked and realized that if the proper parameters were passed via the URL, it would be a simple matter to view categories on the main page... and MORE! Yes, it will be a bit of work, but I think you'll find the time spent making this modification is well-worth the effort. The aim of this modification is to enable filtering of not only categories on your main page, but also archives and tags. The way we do it is to modify the thumbnail and tag links on the archive/browse page to pass the appropriate parameter (archivedate, category, or tag). We retrieve this parameter on our main page and use it to filter our SQL queries, links, and thumbnails. There's no need for additional changes to the database. Everything is passed by URL and two simple function calls determine which URL parameter is passed and what WHERE constraint to add to our SQL. I don't see a way to make this modification into a plugin for the current version of Pixelpost. Therefore you will need to make direct changes to the code. 5 files are modified. The first four are simple modifications (you can make them in a couple of minutes). The last file (index.php) requires quite a few insertions of a variable into the SQL and links. Still, it's not all that difficult and should take you somewhere between 10 to 30 minutes to complete, depending on how familiar you are with PHP coding. Just back up your files and also backup each line you're changing (duplicate the line and then comment one of them out). PROGRAMMING COMMENT I *detest* PHP's concatenation symbol (the period). My editor uses periods to denote tabs. Therefore, it is very difficult for me to distinguish between periods and tab symbols. Also, I strongly disagree with the standard practice of using single quotes (') to enclose strings. I prefer to use double quotes ("). I bring this up because I use the {} delimiters to enclose variables inside of strings. To use these delimiters, you need to use double quotes for strings. So, instead of doing something like $a = 'There are ' . $x . 'items in a dozen' I instead use $a = "There are {$x} items in a dozen". Your delimited variable ({$x}) must be a variable -- no function calls are allowed inside the delimiters. Some of the code below uses these {} delimiters. Now you know what they do. I recommend you don't change anything until *AFTER* you make the cited modifications and ensure everything works. Only then should you go ahead and change things to your own style of coding. MODIFICATIONS 1) MODIFY includes/functions.php You'll need to add two functions to the bottom of the file. Basically, these functions determine what the proper SQL WHERE clause and URL parameters should. function get_sql_constraint ($p_archivedate, $p_category, $p_tag) { // This function returns the proper WHERE clause to add to your SQL statement. global $pixelpost_db_prefix; $archivedate = preg_replace('/[^0-9\-]/', '', $p_archivedate); $archivedate_start = $archivedate ."-01 00:00:00"; $archivedate_end = $archivedate ."-31 23:59:59"; $where_archive = (empty ($p_archivedate)) ? "" : "AND (datetime >='{$archivedate_start}' AND datetime <= '{$archivedate_end}')"; $where_category = (empty ($p_category)) ? "" : "AND id IN (SELECT image_id FROM {$pixelpost_db_prefix}catassoc WHERE cat_id = {$p_category})"; $where_tag = (empty ($p_tag)) ? "" : "AND id IN (SELECT img_id FROM {$pixelpost_db_prefix}tags WHERE tag = '{$p_tag}')"; $constraint = (!empty ($where_archive)) ? $where_archive : $where_category; $constraint = (!empty ($constraint)) ? $constraint : $where_tag; return ($constraint); } function get_url_parameter ($p_archivedate, $p_category, $p_tag) { // This function returns the proper parameter to add to your URL link. $id_archive = (empty ($p_archivedate)) ? "" : "&archivedate={$p_archivedate}"; $id_category = (empty ($p_category)) ? "" : "&category={$p_category}"; $id_tag = (empty ($p_tag)) ? "" : "&tag={$p_tag}"; $parameter = (!empty ($id_archive)) ? $id_archive : $id_category; $parameter = (!empty ($parameter)) ? $parameter : $id_tag; return ($parameter); } 2) MODIFY includes/functions_browse.php This file is called if you DO NOT have the paged_archive addon installed. You'll need to add a line to this file and add a variable to a line. Do a search for thumb_output until you find this line (line 101 in v1.7.3): $thumb_output .= "\"$title\""; Add the get_url_parameter function call above the line. Then, copy and paste the line beneath itself, comment out the orginal line, and then paste $url_parameter after the $id, so it all looks like so: $url_parameter = get_url_parameter ($_GET["archivedate"], $_GET["category"], $_GET["tag"]); // $thumb_output .= "\"$title\""; $thumb_output .= "\"$title\""; 3) MODIFY addons/paged_archive.php This file is called if you DO have the paged_archive addon installed. You'll need to add a line to this file and add a variable to a line. Do a search for thumb_output until you find this line (line 363 in v1.7.3): $thumb_output .= "".$title.""; Add the get_url_parameter function call above the line. Then, copy and paste the line beneath itself, comment out the orginal line, and then paste $url_parameter after the $id, so it all looks like so: $url_parameter = get_url_parameter ($_GET["archivedate"], $_GET["category"], $_GET["tag"]); // $thumb_output .= "".$title.""; $thumb_output .= "".$title.""; 3) MODIFY [path_to_template_files]/image_template.html This is the main page for your website. We add a tag to the image that is displayed so it contains the appropriate URL parameter. Do a search for until you find this line (line 28 in v1.7.3): Add a tag immediately after , so it looks like so: 4) MODIFY /index.php There are a LOT of changes we need to make here. Mostly, you'll be inserting a variable into the SQL and links. I'll provide the line numbers for v1.7.3. If you have a different version, or highly modified version of PixelPost, then look for the variables referenced in the lines. We'll make several passes through this file, so we can concentrate on doing one thing at a time. The 1st pass will be to change the links. a) Find (line 425 in v1.7.3) if(!isset($_GET['x'])) { Add a call to the get_url_parameter function if(!isset($_GET['x'])) { $url_parameter = get_url_parameter ($_GET["archivedate"], $_GET["category"], $_GET["tag"]); b) Find (line 535 in v1.7.3) $image_previous_link = "$lang_previous"; Add the url_parameter to the link. // $image_previous_link = "$lang_previous"; $image_previous_link = "$lang_previous"; c) Find (line 541 in v1.7.3) $image_previous_thumbnail = "$image_previous_title"; Add the url_parameter to the link. // $image_previous_thumbnail = "$image_previous_title"; $image_previous_thumbnail = "$image_previous_title"; d) Find (line 574 in v1.7.3) $image_next_link = "$lang_next"; Add the url_parameter to the link. // $image_next_link = "$lang_next"; $image_next_link = "$lang_next"; e) Find (line 577 in v1.7.3) $image_next_thumbnail = "$image_next_title"; Add the url_parameter to the link. // $image_next_thumbnail = "$image_next_title"; $image_next_thumbnail = "$image_next_title"; f) Find (line 609 in v1.7.3) $first_image_link = "$lang_first"; Add the url_parameter to the link. // $first_image_link = "$lang_first"; $first_image_link = "$lang_first"; g) Find (line 613 in v1.7.3) $first_image_thumbnail = "$first_image_title"; Add the url_parameter to the link. // $first_image_thumbnail = "$first_image_title"; $first_image_thumbnail = "$first_image_title"; h) Find (line 644 in v1.7.3) $last_image_link = "$lang_latest"; Add the url_parameter to the link. // $last_image_link = "$lang_latest"; $last_image_link = "$lang_latest"; i) Find (line 648 in v1.7.3) $last_image_thumbnail = "$last_image_title"; Add the url_parameter to the link. // $last_image_thumbnail = "$last_image_title"; $last_image_thumbnail = "$last_image_title"; j) Find (line 702 in v1.7.3) $ahead_thumbs .= "$headline"; $ahead_thumbs_reverse = "$headline" .$ahead_thumbs_reverse ; Add the url_parameter to the link. // $ahead_thumbs .= "$headline"; // $ahead_thumbs_reverse = "$headline" .$ahead_thumbs_reverse ; $ahead_thumbs .= "$headline"; $ahead_thumbs_reverse = "$headline" .$ahead_thumbs_reverse ; k) Find (line 727 in v1.7.3) $behind_thumbs = "$headline$behind_thumbs"; $behind_thumbs_reverse .= "$headline"; Add the url_parameter to the link. // $behind_thumbs = "$headline$behind_thumbs"; // $behind_thumbs_reverse .= "$headline"; $behind_thumbs = "$headline$behind_thumbs"; $behind_thumbs_reverse .= "$headline"; l) Find (line 735 in v1.7.3) $thumbnail_row = "$behind_thumbs$image_title$ahead_thumbs"; $thumbnail_row_reverse = "$ahead_thumbs_reverse$image_title$behind_thumbs_reverse"; Add the url_parameter to the link. // $thumbnail_row = "$behind_thumbs$image_title$ahead_thumbs"; // $thumbnail_row_reverse = "$ahead_thumbs_reverse$image_title$behind_thumbs_reverse"; $thumbnail_row = "$behind_thumbs$image_title$ahead_thumbs"; $thumbnail_row_reverse = "$ahead_thumbs_reverse$image_title$behind_thumbs_reverse"; The 2nd pass will be to change the SQL. a) Find (line 512 in v1.7.3) // get previous image id and name Add a call to get the WHERE constraint. // get previous image id and name $where_constraint = get_sql_constraint ($_GET["archivedate"], $_GET["category"], $_GET["tag"]); b) Find (line 515 in v1.7.3) //public $previous_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate') ORDER BY datetime desc limit 0,1"); Copy and change it to add the WHERE constraint to the SQL. //public // $previous_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate') ORDER BY datetime desc limit 0,1"); $previous_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate') {$where_constraint} ORDER BY datetime desc limit 0,1"); c) Find (line 519 in v1.7.3) //admin $previous_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') ORDER BY datetime desc limit 0,1"); Copy and change it to add the WHERE constraint to the SQL. //admin // $previous_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') ORDER BY datetime desc limit 0,1"); $previous_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') {$where_constraint} ORDER BY datetime desc limit 0,1"); d) Find (line 554 in v1.7.3) //public $next_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate') ORDER BY datetime asc limit 0,1"); Copy and change it to add the WHERE constraint to the SQL. //public // $next_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate') ORDER BY datetime asc limit 0,1"); $next_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate') {$where_constraint} ORDER BY datetime asc limit 0,1"); e) Find (line 558 in v1.7.3) //admin $next_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') ORDER BY datetime asc limit 0,1"); Copy and change it to add the WHERE constraint to the SQL. //admin // $next_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') ORDER BY datetime asc limit 0,1"); $next_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') {$where_constraint} ORDER BY datetime asc limit 0,1"); f) Find (line 590 in v1.7.3) //public $first_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') ORDER BY datetime asc limit 0,1"); Copy and change it to add the WHERE constraint to the SQL. //public // $first_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') ORDER BY datetime asc limit 0,1"); $first_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') {$where_constraint} ORDER BY datetime asc limit 0,1"); g) Find (line 594 in v1.7.3) //admin $first_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost ORDER BY datetime asc limit 0,1"); Copy and change it to add the WHERE constraint to the SQL. IMPORTANT!!! Note that we also add the WHERE clause from the previous SQL query. We need to do this because there is no WHERE clause define in the where_constraint and not having one will result in a database error. The WHERE clause is the same as the query above, so the correct results should be returned. //admin // $first_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost ORDER BY datetime asc limit 0,1"); $first_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') {$where_constraint} ORDER BY datetime asc limit 0,1"); h) Find (line 624 in v1.7.3) //public $last_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') ORDER BY datetime desc limit 0,1"); Copy and change it to add the WHERE constraint to the SQL. //public // $last_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') ORDER BY datetime desc limit 0,1"); $last_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') {$where_constraint} ORDER BY datetime desc limit 0,1"); i) Find (line 628 in v1.7.3) //admin $last_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') ORDER BY datetime desc limit 0,1"); Copy and change it to add the WHERE constraint to the SQL. //admin // $last_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') ORDER BY datetime desc limit 0,1"); $last_image_row = sql_array("SELECT id,headline,alt_headline,image,datetime FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime<='$cdate') {$where_constraint} ORDER BY datetime desc limit 0,1"); j) Find (line 663 in v1.7.3) $aheadnumb = sql_array("SELECT count(*) as count FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate')"); Copy and change it to add the WHERE constraint to the SQL. // $aheadnumb = sql_array("SELECT count(*) as count FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate')"); $aheadnumb = sql_array("SELECT count(*) as count FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate') {$where_constraint}"); k) Find (line 666 in v1.7.3) $behindnumb = sql_array("SELECT count(*) as count FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate')"); Copy and change it to add the WHERE constraint to the SQL. // $behindnumb = sql_array("SELECT count(*) as count FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate')"); $behindnumb = sql_array("SELECT count(*) as count FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate') {$where_constraint}"); l) Find (line 686 in v1.7.3) $thumbs_ahead = mysql_query("SELECT id,headline,alt_headline,image FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate') ORDER BY datetime asc limit 0,$aheadlimit"); Copy and change it to add the WHERE constraint to the SQL. // $thumbs_ahead = mysql_query("SELECT id,headline,alt_headline,image FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate') ORDER BY datetime asc limit 0,$aheadlimit"); $thumbs_ahead = mysql_query("SELECT id,headline,alt_headline,image FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime > '$image_datetime') and (datetime<='$cdate') {$where_constraint} ORDER BY datetime asc limit 0,$aheadlimit"); m) Find (line 711 in v1.7.3) $thumbs_behind = mysql_query("SELECT id,headline,alt_headline,image FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate') ORDER BY datetime desc limit 0,$behindlimit"); Copy and change it to add the WHERE constraint to the SQL. // $thumbs_behind = mysql_query("SELECT id,headline,alt_headline,image FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate') ORDER BY datetime desc limit 0,$behindlimit"); $thumbs_behind = mysql_query("SELECT id,headline,alt_headline,image FROM ".$pixelpost_db_prefix."pixelpost WHERE (datetime < '$image_datetime') and (datetime<='$cdate') {$where_constraint} ORDER BY datetime desc limit 0,$behindlimit"); The 3rd pass adds a line to accomodate a new template tag. Find (line 822 in v1.7.3) $tpl = ereg_replace("",$first_image_thumbnail,$tpl); Add a new line for our URL_PARAMETER tag. $tpl = ereg_replace("",$first_image_thumbnail,$tpl); $tpl = ereg_replace("",$url_parameter,$tpl); That's it! Now, when you use archive/browse your results are made part of the thumbnail and tag URLs. When you click on the thumbnail or tag, images on your main page will be constrained to the archivedate, category, or tag you chose. The constraint remains in effect until: A) You go back to archive/browse and choose a different constraint. B) You click on your site title, which takes you back to the most current photo. The URL for this is http://yoursite/ and seeing as there are no parameters, all constraints are removed. Enjoy!