PDA

View Full Version : Issue with paged_archive and images with no category


mello
09-16-2005, 03:46 PM
Hey,

I ran into an issue with images that don't have a category associated with them and the paged_archive addon. Basically when viewing 'all' images, the images with no category are not shown. I tested this with both the paged_archive addon from pp 1.4.2 and also the latest from cvs.

Here's a fix for it as well:

Originally paged_archive.php contains about halfway through, the following:

// did user select a category?

if($_GET['category'] != "") { $where = "and (t2.cat_id ='".$_GET['category']."')"; }

// do you use links with page number?
if ($_GET['pagenum'] != "") {
$start = $maxnumber_thumbs*($_GET['pagenum']-1);// calculate start and end of the thumbs in the selected page
$limit = " limit $start , $maxnumber_thumbs "; // create the limit command (in MS-SQL this should be TOP)
}// end if ($_GET['pagenum'] != "")

// build query
if ($_GET['archivedate']=="")
{
// no archive date
$query = "select t1.id,t1.headline,t1.image from {$pixelpost_db_prefix}pixelpost as t1
inner join {$pixelpost_db_prefix}catassoc as t2
where (t1.datetime<='$cdate')
$where
and t1.id = t2.image_id
group by t1.id
order by t1.datetime desc" .$limit;

I modified this, to look as follows:

// did user select a category?

if($_GET['category'] != "") { $where = "and (t2.cat_id ='".$_GET['category']."') and t1.id = t2.image_id"; }

// do you use links with page number?
if ($_GET['pagenum'] != "") {
$start = $maxnumber_thumbs*($_GET['pagenum']-1);// calculate start and end of the thumbs in the selected page
$limit = " limit $start , $maxnumber_thumbs "; // create the limit command (in MS-SQL this should be TOP)
}// end if ($_GET['pagenum'] != "")

// build query
if ($_GET['archivedate']=="")
{
// no archive date
$query = "select t1.id,t1.headline,t1.image from {$pixelpost_db_prefix}pixelpost as t1
inner join {$pixelpost_db_prefix}catassoc as t2
where (t1.datetime<='$cdate')
$where
group by t1.id
order by t1.datetime desc" .$limit;

so basically, I moved the and t1.id = t2.image_id out of the $query definition up into the if($_GET['category'] != "")statement.

regards,

mello