Hi!
Whit this mod you can show Random Images from the Subcategories, instead of the Subcategories names
1.) create a new file "random_subcat_image.html" and store it in templates/yourTemplate:
{thumbnail_small}
2.) search in includes/constans.php:
define('SHOW_RANDOM_CAT_IMAGE', 0);
insert below:
define('SHOW_RANDOM_SUBCAT_IMAGE', 1);
define('RANDOM_SUBCAT_IMAGE_WIDTH', 45);
3.) search in includes/functions.php
"thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link),
insert below:
//################################# Start Thumbnail small Code #####################################################
"thumbnail_small" => get_thumbnail_small_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link),
//################################# End Thumbnail small Code #######################################################
3.1) search:
function get_thumbnail_code($media_file_name, $thumb_file_name = "", $image_id, $cat_id, $image_name = "", $mode = "", $show_link = 1, $open_window = 0) {
insert above:
//################################# Start Thumbnail small Code ########################################################
function get_thumbnail_small_code($media_file_name, $thumb_file_name = "", $image_id, $cat_id, $image_name = "", $mode = "", $show_link = 1, $open_window = 0) {
global $site_sess, $config, $site_template;
$maxwidth = RANDOM_SUBCAT_IMAGE_WIDTH;
if (!check_media_type($media_file_name)) {
$thumb = "<img src=\"".ICON_PATH."/404.gif\" border=\"0\" alt=\"\" >";
}
else {
if (!get_file_path($media_file_name, "thumb", $cat_id, 0, 0)) {
$file_src = ICON_PATH."/".get_file_extension($media_file_name).".gif";
$image_info = @getimagesize($file_src);
$thumb_width = $image_info[0]."px";
$thumb_height = $image_info[1]."px";
$thumb = "<img src=\"".$file_src."\" style=\"border:0px;width:$thumb_width; height:$thumb_height;\" alt=\"".format_text($image_name, 2)."\" >";
}
else {
$file_src = get_file_path($media_file_name, "thumb", $cat_id, 0, 1);
$image_info = @getimagesize($file_src);
$thumb_width = $image_info[0];
$thumb_height = $image_info[1];
if ($thumb_width > $maxwidth){
$imageprop=$maxwidth/$thumb_width;
$imagevsize= $thumb_height*$imageprop;
$thumb_width=$maxwidth."px";
$thumb_height= round($imagevsize)."px";
}
else{
$thumb_width = $image_info[0]."px";
$thumb_height = round($image_info[1])."px";
}
$thumb = "<img src=\"".$file_src."\" style=\"border:".$config['image_border']."px solid;width:$thumb_width; height:$thumb_height;\" alt=\"".format_text($image_name, 2)."\">";
}
}
if ($show_link) {
if ($open_window) {
$thumb = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))." #z1\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".$thumb."</a>";
}
else {
$thumb = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : ""))." #z1\">".$thumb."</a>";
}
}
return $thumb;
}
//################################# End Thumbnail small Code ########################################################
3.2) search:
if (SHOW_RANDOM_CAT_IMAGE) {
(below "$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");")
and replace:
if (SHOW_RANDOM_CAT_IMAGE || SHOW_RANDOM_SUBCAT_IMAGE) {
3.3) search:
else {
$template = 'random_image';
insert above:
//############# Start Random Images from the Subcategories #################
if ($cat_id && SHOW_RANDOM_SUBCAT_IMAGE) {
$template = 'random_subcat_image';
$category_id = $cat_id;
}
//############# End Random Images from the Subcategories ###################
3.4) search:
$sub_cat_list .= "<a href=\"".$sub_url."\" class=\"subcat\">".format_text($cat_cache[$subcat_id]['cat_name'], 2)."</a>";
if ($i != $config['num_subcats'] && $i < $config['num_subcats'] && $i < $num_subs) {
$sub_cat_list .= ", ";
and replace:
//############## Start Random Images from the Subcategories ###########################################
$link = 1; // "0" is called the sub categorie, "1" is called the details.html
$random_subcat_image_file = (SHOW_RANDOM_SUBCAT_IMAGE) ? get_random_image($subcat_id,$link, 0) :"";
$subcat_image_file = ($random_subcat_image_file) ? $random_subcat_image_file : format_text($cat_cache[$subcat_id]['cat_name'], 2);
$sub_cat_list .= "<a href=\"".$sub_url."\" class=\"subcat\">".$subcat_image_file."</a>";
//############## End Random Images from the Subcategories ###########################################
if ($i != $config['num_subcats'] && $i < $config['num_subcats'] && $i < $num_subs) {
$sub_cat_list .= ($random_subcat_image_file)? " ":", "; // Random Images from the Subcategories ($sub_cat_list .= ", ");
mfg Andi