4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: masumcis on February 14, 2008, 12:07:22 PM
-
hi,
i want to show some selected (may be 1/2) pic in my home page.
but i dont know how to do it. plz advice me.
i m using 1.7.4 ver
-
// Step 1
In index.php file,
find:
unset ($new_images);
add after:
//-----------------------------------------------------
//--- Selected pic ------------------------------------
//-----------------------------------------------------
if (defined('USE_SELECTED_PIC') && USE_SELECTED_PIC == 1) {
$site_template->register_vars(array(
"has_rss" => true,
"rss_title" => "RSS Feed: ".format_text($config['site_name'], 2)." (".str_replace(':', '', $lang['selected_pic_title']).")",
"rss_url" => $script_url."/rss.php?action=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;
}
}
$num_selected_pic = $config['image_cells'];
$additional_selected_pic_implode = implode(", ", $additional_selected_pics);
$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 i.image_id IN (" . $additional_selected_pic_implode . ") AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
ORDER BY i.image_date DESC
LIMIT $num_selected_pic";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows) {
$selected_pic = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
$selected_pic .= $lang['no_selected_pic'];
$selected_pic .= "</td></tr></table>";
}
else {
$selected_pic = "<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;
$selected_pic .= "<tr class=\"imagerow".$row_bg_number."\">\n";
}
$selected_pic .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
show_image($image_row);
$selected_pic .= $site_template->parse_template("thumbnail_bit");
$selected_pic .= "\n</td>\n";
$count++;
if ($count == $config['image_cells']) {
$selected_pic .= "</tr>\n";
$count = 0;
}
} // end while
if ($count > 0) {
$leftover = ($config['image_cells'] - $count);
if ($leftover >= 1) {
for ($f = 0; $f < $leftover; $f++) {
$selected_pic .= "<td width=\"".$imgtable_width."\">\n \n</td>\n";
}
$selected_pic .= "</tr>\n";
}
}
$selected_pic .= "</table>\n";
} // end else
$site_template->register_vars("selected_pic", $selected_pic);
unset($selected_pic);
}
// Step 2
In includes/db_field_definitions.php file,
add in top ?>:
$additional_selected_pics = array("1", "2", "3"); // Each image IDs
// Step 3
In includes/constants.php file,
add in top ?>:
define('USE_SELECTED_PIC', 1); // 1 = Active and 0 = no active.
// Step 4
In main/english/main.php file,
add in top ?>:
$lang['selected_pic_title'] = "Selected pic";
$lang['no_selected_pic'] = "No selected pic";
// Step 5
In includes/page_header.php file,
find:
"lang_new_images" => $lang['new_images'],
add after:
"lang_selected_pic_title" => $lang['selected_pic_title'],
// Step 6
In templates/your_template/home.html file, use: {if selected_pic}{lang_selected_pic_title}{selected_pic}{endif selected_pic} where you like. ;)
// Is work.
- In includes/constants.php file (USE_SELECTED_PIC define) is for set active / no active in home page.
- In includes/db_field_definitions.php file ($additional_selected_pic array) is for set each image ID you like for select pic. ;)
Finish.
-
Thank you veeeeeeeeeeeery much. :lol:
-
hi i did it and it seems nothing happen. no pic on there. what to do. and what will be my images id and where to finr it. :|
-
no pic on there. what to do.
ACP - > Categories and check for all setting.
[edit] - I fix step 1. ;)
-
i chack every thing but igot a error msg like this:
Warning: implode(): Bad arguments. in /home/www/bdpicture/4images_gallery/index.php on line 182
DB Error: Bad SQL Query: 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, c.cat_name, u.user_name FROM (4img_images i, 4img_categories c) LEFT JOIN 4img_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND i.image_id IN () AND c.cat_id = i.cat_id AND i.cat_id NOT IN (0) ORDER BY i.image_date DESC LIMIT 3
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND c.cat_id = i.cat_id AND i.cat_id NOT IN (0) ORDER
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/bdpicture/4images_gallery/includes/db_mysql.php on line 116
what to do :roll:
-
Typo error. Try step 1 again. I fix. ;)
-
Thanks, let me chack :lol:
-
Hi,
Is there a way to display more selected pictures?
Now we have:
$additional_selected_pics = array("1", "2", "3"); // Each image IDs
If I change this to:
$additional_selected_pics = array("1", "2", "3", "4", "5", "6", "7", "8", "9"); // Each image IDs
still shows only 3 pictures!
OK I found this solution and it works:
$num_selected_pic = 12;
$num_additional_selected_pics = 12;