Author Topic: {new_images} from specific category  (Read 18286 times)

0 Members and 1 Guest are viewing this topic.

Offline zoomos

  • Newbie
  • *
  • Posts: 14
    • View Profile
{new_images} from specific category
« 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);

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: {new_images} from specific category
« Reply #1 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..
cheers
Nicky
Your first three "must do" before you ask a question ! ( by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline KimmyMarie

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: {new_images} from specific category
« Reply #2 on: October 17, 2006, 08:50:52 PM »
Which template is this?



Thanks,
Kimmy

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: {new_images} from specific category
« Reply #3 on: October 17, 2006, 09:00:21 PM »
file index.php
cheers
Nicky
Your first three "must do" before you ask a question ! ( by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline murad

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: {new_images} from specific category
« Reply #4 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

Offline webmaster73

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: {new_images} from specific category
« Reply #5 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.



Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: {new_images} from specific category
« Reply #6 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). ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline webmaster73

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: {new_images} from specific category
« Reply #7 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.


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: {new_images} from specific category
« Reply #8 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. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline webmaster73

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: {new_images} from specific category
« Reply #9 on: August 10, 2007, 12:21:38 AM »
thank you very much

Offline IndianMonk

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Img Hunt
Re: {new_images} from specific category
« Reply #10 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?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: {new_images} from specific category
« Reply #11 on: August 19, 2007, 03:33:35 PM »
I use v1.7.4 too. :?
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline GaYan

  • Sr. Member
  • ****
  • Posts: 301
  • ♫ | G2 | ♫
    • View Profile
    • Ziramagic
Re: {new_images} from specific category
« Reply #12 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
I'm Back :)

 

Post your comments here