4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started 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...
//-----------------------------------------------------
//--- 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 \n</td>\n";
}
$new_images .= "</tr>\n";
}
}
$new_images .= "</table>\n";
} // end else
$site_template->register_vars("new_images", $new_images);
unset($new_images);
-
try this
change:
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
to:
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..
-
Which template is this?
Thanks,
Kimmy
-
file index.php
-
Hello,
How can i show last 10 new images like that
http://www.s60m.com/themes/newbluetooth.php
Thanks
-
try this
change:
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
to:
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.
-
Is constants.php do if no config in ACP ? ;) If so, can code it (fast and no hi ressourc). ;)
-
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.
-
Ok, so here:
http://www.4homepages.de/forum/index.php?topic=15057.msg80804#msg80804
find:
$new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
add before:
$show_new_images_ids = (isset($show_new_images_ids)) ? implode(", ", $show_new_images_ids) : 0;
http://www.4homepages.de/forum/index.php?topic=15057.msg80827#msg80827
replace Nicky replace for:
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 ?>
$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. ;)
-
thank you very much
-
I m using 1.7.4. I could not find that line:
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:
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?
-
I use v1.7.4 too. :?
-
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