Author Topic: [Request] Top 25 Categories?  (Read 4190 times)

0 Members and 1 Guest are viewing this topic.

Offline praveen

  • Newbie
  • *
  • Posts: 36
    • View Profile
[Request] Top 25 Categories?
« on: November 04, 2015, 01:59:33 PM »
I am trying to setup a Top 25 that shows the popular categories in the last one week with a random thumbnail for each category.

After going through the forums, i created this but this does not show unique categories. Instead it shows recently added images :(

Can someone help?


function getDaysInWeek($week="",$year=""){  
  
$year = ($year) ? $year date("Y");
  
$week = ($week) ? $week date("W");
  
$time strtotime($year.'0104+'.($week 1).'weeks');
  
$mondayTime strtotime('-'.(date('w',$time)-1).'days',$time);
  
$dayTimes = array(); 
  for (
$i 0$i 7;++$i){ 
    
$dayTimes[] = strtotime('+'.$i.'days'$mondayTime); 
    
//$dayTimes[] = date("d.m.Y",strtotime('+'.$i.'days', $mondayTime));
  

  return 
$dayTimes
}
$lastweek date("W") -1;
$weekday getDaysInWeek($lastweek);

$num_new_images $config['image_cells'];
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN ("
.get_auth_cat_sql("auth_viewcat""NOTIN").") AND i.image_date BETWEEN ".$weekday[0]." AND ".($weekday[6] + 86399)."
        ORDER BY i.image_hits DESC
        LIMIT 25
        "
;
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$last_week "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  
$last_week .= "No Images last week !";
  
$last_week .= "</td></tr></table>";
}
else  {
  
$last_week "<ul>";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){

    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
     
// $last_week .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    
}
    
$last_week .= "<li>\n";

    
show_image($image_row);
    
$last_week .= $site_template->parse_template("thumbnail_bit");
    
$last_week .= "\n</li>\n";
    
$count++;
    if (
$count == $config['image_cells']) {
    
//  $last_week .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
        
$last_week .= "<li>\n&nbsp;\n</li>\n";
      }
      
//$last_week .= "</tr>\n";
    
}
  }
  
$last_week .= "</ul>\n";
// end else

$site_template->register_vars("last_week"$last_week);
unset(
$last_week);

Offline praveen

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: [Request] Top 25 Categories?
« Reply #1 on: November 17, 2015, 03:53:24 AM »
Bump