NOT MY MOD, FOUND IN GOOGLE CACHE! NO SUPPORT!Mod Author: rproctor
PAGING PROBLEM GELÖSTYou can go hee to my test site which I mess with code and what not. This is a direct link to a main category which has the master_cat turned on and this mod installed.
http://www.digitalgod.biz/test/categories.php?cat_id=4I needed a way to better organize my categories. I didnt want my main categories to have any submissions, only my sub categories, but it looks so ugly when you view a main category and it says 0 images found. So, instead with a few tweeks, I made categories that I selected display the images of the subcategories.
The downfall is that if you select a category to display subcat images, it will only display FIRST LEVEL sub cat images. Also, if you upload an image where it is specified to show sub cat images, the image will now show up in the category, this is why you should only upload to sub cats that are not checked to disply subcat images. However, you can check sub cats to display sub cat images if that sub cat has a sub cat. Sub cat main cat blue cat green cat... Confused yet? Wink
1) First thing to do is create a field in the CATEGORIES_TABLE using a program like PHPMyAdmin. This field should be named cat_master and a type of tinyint(1), not null, and 0 for default.
2) Now, the boring part. Its time to edit the admin category file so that we can edit this field via ACP. Open admin/categories.php and find
$cat_hits = intval(trim($HTTP_POST_VARS['cat_hits']));
Add after
$cat_master = intval(trim($HTTP_POST_VARS['cat_master']));
2.1) find
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
Replace with
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, cat_master = $cat_master
2.2) find
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
Replace with
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_master
2.3) find
show_input_row($lang['field_hits'], "cat_hits", $result['cat_hits'], 5);
add after
show_radio_row("cat_master", "cat_master", $result['cat_master']);
2.4) find
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
Replace with
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_master
/
3) Now its time to make it work. Open 4images/categories.php and find
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
Add right before it
$sql = "SELECT cat_master
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_id";
$master_cat = $site_db->query_firstrow($sql);
3.1) Next find
"cat_name" => htmlspecialchars($cat_cache[$cat_id]['cat_name']),
Change to
"cat_name2" => htmlspecialchars($cat_cache[$cat_id]['cat_name']),
in 4images v1.7.6 find:
"cat_name" => format_text($cat_cache[$cat_id]['cat_name'], 2),
Change to
"cat_name2" => format_text($cat_cache[$cat_id]['cat_name'], 2),
3.2) Find
if (!$num_rows) {
$thumbnails = "";
$msg = $lang['no_images'];
}
Replace with
if (!$num_rows) {
$thumbnails = "";
if ($master_cat['cat_master'] == 1){
$msg = "";
}
else{
$msg = $lang['no_images'];
}
}
3.3) Now find
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);
Add below
//-----------------------------------------------------
//--- Show Sub Images ---------------------------------
//-----------------------------------------------------
if ($master_cat['cat_master'] == 1){
$sql = "SELECT cat_parent_id
FROM ".CATEGORIES_TABLE."
WHERE cat_parent_id = $cat_id";
$total_subs = $site_db->query($sql);
$num_subs = $site_db->get_numrows($total_subs);
$sql = "SELECT i.image_id, i.cat_id, i.image_active, c.cat_parent_id
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
WHERE i.image_active = 1 AND c.cat_parent_id = $cat_id AND c.cat_id = i.cat_id";
$result2 = $site_db->query($sql);
$num_rows2 = $site_db->get_numrows($result2);
$link_arg = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);
//include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows2, $link_arg);
$offset = $getpaging->get_offset();
$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_parent_id, 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_parent_id = $cat_id AND c.cat_id = i.cat_id
ORDER BY ".$config['image_order']." ".$config['image_sort']."
LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
$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;
}
}
if (!$num_rows) {
$thumbnails = "";
$msg = $lang['no_images'];
}
else {
$thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)){
if ($count == 0) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
}
$thumbnails .= "<td width=\"".$imgtable_width."\" =\"top\">\n";
show_image($image_row);
$thumbnails .= $site_template->parse_template("thumbnail_bit");
$thumbnails .= "\n</td>\n";
$count++;
if ($count == $config['image_cells']) {
$thumbnails .= "</tr>\n";
$count = 0;
}
} // end while
if ($count > 0) {
$leftover = ($config['image_cells'] - $count);
if ($leftover > 0) {
for ($i = 0; $i < $leftover; $i++){
$thumbnails .= "<td width=\"".$imgtable_width."\">\n \n</td>\n";
}
$thumbnails .= "</tr>\n";
}
}
$thumbnails .= "</table>\n";
} //end else
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);
}
4) Here is the last and easiest part. Open 4images/templates/<your_template>/categories.php and change {cat_name} to {cat_name2}.
5) Now upload your edited files to your site. Next enter your ACP and select "Edit categories". You should notice a new field under hits called cat_master, change this to yes to enable this mod for that category. Dont forget, if you upload an image to that category and it has cat_master enabled that image will now show, so you should disable uploading for that category.
Thats about it, hope it works ok, I tested my own instructions on a new installation to make sure I did everything right, and it all seems to be ok.
DEMO:
http://www.hobby-fotografen.com/categories.php?cat_id=19ps: sorry for my bad english :/
so, habe das pagingproblem nun doch in den griff bekommen, und der mod funktioniert jetzt einwandfrei (vielleicht nicht sauber gecodet - funzt aber
)