With this mod you can the same image in multiple categories show.
This modification has long on the wish list, some user.
1.) add new field into 4images_images table:
ALTER TABLE 4images_images ADD image_multicat VARCHAR(255) NOT NULL
or download attached install_image_multi.php file, upload it to your 4images root directory and executed it.
2.) search in includes/db_field_definitions.php:
?>
insert above:
//-----------------------------------------------------
//--- Multicat -----------------------------------------
//-----------------------------------------------------
$additional_image_fields['image_multicat'] = array($lang['image_multicat'], "text", 0);
3.) search in lang/english/main.php:
?>
insert above:
//-----------------------------------------------------
//--- Multicat -----------------------------------------
//-----------------------------------------------------
$lang['image_multicat'] = "Multi Cat:<br /><span class=\"smalltext\">Cat_ID's must be separated by commas.</span>";
3.1) lang/deutsch/main.php
//-----------------------------------------------------
//--- Multicat -----------------------------------------
//-----------------------------------------------------
$lang['image_multicat'] = "Multi Cat:<br /><span class=\"smalltext\">Cat_ID's mittels Kommas getrennt eingeben.</span>";
4.) search in root/categories.php
unset($random_cat_image);
insert below:
//#################### Multi Cat Start ########################################
$sql = "SELECT image_id,cat_id,image_multicat
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND cat_id NOT IN ($cat_id)";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)){
$keys = explode(',',$row['image_multicat']);
if (in_array( $cat_id, $keys)) {
$multicat[] = $row['image_id'];
}
}
$multicount = count($multicat);
$multicat = (isset($multicat)) ? "or i.image_id IN (".implode(", ",$multicat).")" : "";
//#################### Multi Cat End ########################################
4.1) search in root/categories.php
$num_rows_all = (isset($cat_cache[$cat_id]['num_images'])) ? $cat_cache[$cat_id]['num_images'] : 0;
insert below:
$num_rows_all = $num_rows_all + $multicount;
4.2) search in root/categories.php
WHERE i.image_active = 1 AND i.cat_id = $cat_id AND c.cat_id = i.cat_id
and replace:
WHERE i.image_active = 1 AND i.cat_id = $cat_id AND c.cat_id = i.cat_id $multicat Group by image_id
4.3) search in root/categories.php
show_image($image_row);
insert below:
$thumbnails .= $site_template->register_vars("cat_name",$cat_cache[$image_row['cat_id']]['cat_name']);
4.4) search in root/categories.php:
$site_template->register_vars("thumbnails", $thumbnails);
insert above:
$site_template->register_vars("cat_name",$cat_cache[$cat_id]['cat_name']);
5.) search in root/index.php:
show_image($image_row);
insert below:
$site_template->register_vars("cat_name",$cat_cache[$image_row['cat_id']]['cat_name']);
6.) search in includes/functions.php:
$random_cat_image_file = get_random_image($category_id, 0, 1);
}
insert below:
//#################### Multi Cat Start ######################################
$multicount ="";
$sql = "SELECT image_id,cat_id,image_multicat
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND cat_id NOT IN ($category_id)";
$result = $site_db->query($sql);
$multicat = array();
while ($row = $site_db->fetch_array($result)){
$keys = explode(',',$row['image_multicat']);
if (in_array($category_id, $keys)) {
$multicat[] = $row['image_id'];
}
}
$multicount = count($multicat);
//#################### Multi Cat End ########################################
search:
"num_images" => $num_images
and replace:
"num_images" => $num_images +$multicount
In "Edit images" can you now write the Categorienumbers.
i hope it's all.
mfg Andi