4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: zoomos on October 16, 2006, 08:21:25 PM

Title: {new_images} from specific category
Post by: zoomos on October 16, 2006, 08:21:25 PM
I'm trying to edit {new_images} Random Code to only get from a specific category.. I searched this forum for 2 hours and couldn't find one for new images

Can't figure out what to change...
Code: [Select]
//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------
$imgtable_width = ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}

$new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
$num_new_images = $config['image_cells'];
$sql = "SELECT IF(i.image_date >= $new_cutoff,RAND()+1,1) as random_no, 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 IN (".get_auth_cat_sql("auth_viewcat").")
       ORDER BY random_no DESC, i.image_date DESC
       LIMIT $num_new_images";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  $new_images .= $lang['no_new_images'];
  $new_images .= "</td></tr></table>";
}
else  {
  $new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

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

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

$site_template->register_vars("new_images", $new_images);
unset($new_images);
Title: Re: {new_images} from specific category
Post by: Nicky on October 17, 2006, 12:51:58 AM
try this

change:
Code: [Select]
       WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")

to:
Code: [Select]
       WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (5, 17, 55)

where (5, 17, 55) are your category numbers

pls note, that this change will show hidden category pics too..
Title: Re: {new_images} from specific category
Post by: KimmyMarie on October 17, 2006, 08:50:52 PM
Which template is this?



Thanks,
Kimmy
Title: Re: {new_images} from specific category
Post by: Nicky on October 17, 2006, 09:00:21 PM
file index.php
Title: Re: {new_images} from specific category
Post by: murad on November 01, 2006, 08:44:26 AM
Hello,
How can i show last 10 new images like that
http://www.s60m.com/themes/newbluetooth.php
Thanks
Title: Re: {new_images} from specific category
Post by: webmaster73 on August 09, 2007, 04:43:07 PM
try this

change:
Code: [Select]
       WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")

to:
Code: [Select]
       WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (5, 17, 55)

where (5, 17, 55) are your category numbers

pls note, that this change will show hidden category pics too..

this is really lovely. but once again dear 4images coders, this must be a setting in the admin panel, not a hack to the script.


Title: Re: {new_images} from specific category
Post by: thunderstrike on August 09, 2007, 10:30:26 PM
Is constants.php do if no config in ACP ? ;) If so, can code it (fast and no hi ressourc). ;)
Title: Re: {new_images} from specific category
Post by: webmaster73 on August 09, 2007, 11:07:57 PM
Is constants.php do if no config in ACP ? ;) If so, can code it (fast and no hi ressourc). ;)

yes admin control panel is not a necessity....  if you make it an option in constants.php, fine and fair enough.

Title: Re: {new_images} from specific category
Post by: thunderstrike on August 09, 2007, 11:32:18 PM
Ok, so here:

http://www.4homepages.de/forum/index.php?topic=15057.msg80804#msg80804

find:

Quote
$new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];

add before:

Quote
$show_new_images_ids = (isset($show_new_images_ids)) ? implode(", ", $show_new_images_ids) : 0;

Quote
http://www.4homepages.de/forum/index.php?topic=15057.msg80827#msg80827

replace Nicky replace for:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (" . $show_new_images_ids . ")

In includes/constants.php file,

before ?>

Quote
$show_new_images_ids = array(1, 2, 3, 4, 5);

replace: 1, 2, 3, 4, 5 with IDs need (comma must use with space).

Done. ;)
Title: Re: {new_images} from specific category
Post by: webmaster73 on August 10, 2007, 12:21:38 AM
thank you very much
Title: Re: {new_images} from specific category
Post by: IndianMonk on August 19, 2007, 08:07:02 AM
I m using 1.7.4. I could not find that line:
Code: [Select]
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
I find this line:
Code: [Select]
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").")
Wat should I do?
Title: Re: {new_images} from specific category
Post by: thunderstrike on August 19, 2007, 03:33:35 PM
I use v1.7.4 too. :?
Title: Re: {new_images} from specific category
Post by: GaYan on January 15, 2010, 05:29:51 AM
can we set something like this...

in 1 raw... we are showing the latest pictures from category (1)
in the 2nd raw its the 2nd cats latest imges and
in the 3rd cat all new images from whole cat

how can we do this >? plz help