4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Rembrandt on December 09, 2011, 10:27:05 AM

Title: [Mod] Show Random Images from the Subcategories
Post by: Rembrandt on December 09, 2011, 10:27:05 AM
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:
Code: [Select]
{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)) ? "&amp;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)) ? "&amp;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
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: JoBi on January 17, 2013, 05:26:39 PM
Entweder stell ich mich grad blöd an oder ich steh total auf der Leitung!

Wo zeigt es mir den das Thumbnail an??? neben der Kategorie oder????

VG
Josef

bzw. neben der unterkategorie halt
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: Rembrandt on January 17, 2013, 05:43:13 PM
Na du fragst Sachen, das weis ich doch auch nicht mehr  :mrgreen:
Der Mod war ein Quasi "Wunsch", aber ich glaube die Bilder wurden (Ausgehend vom Original Template) unter dem Hauptkategorienamen Angezeigt.
Dazu muß aber im ACP im Feld "Wieviele Subkategorien sollen Angezeigt werden" etwas drinnen stehn.
Dann werden Zufallsbilder  anstatt der Subkategorie Namen dargestellt.

mfg Andi
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: JoBi on January 17, 2013, 07:55:56 PM
Ahhhh cool danke, und ich dachte schon, ich war zu blöd den MOD zu installieren.. Aber wenn man bei subcategories 0 einstellt, kann man das natürlich nicht sehen.....

Ich wollte eigentlich den MOD Category Image installieren, aber ich bring ihn einfach nicht zum laufen, ebenso hab ich es nicht geschafft das mit den random cat Image zum laufen zu bringen. Dabei wollte ich einfach nur, dass meine Kategorien so aussehen wie die jetzigen auf meiner Startseite. Du weißt ja, thumbnail, kleiner 1px Rahmen und den NAmen der Kategorie unter dem Bild. Eigentlich genauso wie bei deinem Mod mit den neuesten Kategorien bei mir auf der home.

LG
Josef

Title: Re: [Mod] Show Random Images from the Subcategories
Post by: Rembrandt on January 18, 2013, 05:49:48 AM
... Dabei wollte ich einfach nur, dass meine Kategorien so aussehen wie die jetzigen auf meiner Startseite....
so vielleicht: http://www.4homepages.de/forum/index.php?topic=30783.msg161958#msg161958
Rahmen mußt du dir halt noch machen.

mfg Andi
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: JoBi on January 18, 2013, 01:22:23 PM
funzt nicht, hab trotzdem keine Bilder zu den Kategorien
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: Rembrandt on January 18, 2013, 02:05:21 PM
dann schreib mal in der includes/constants.php bei "define('SHOW_RANDOM_CAT_IMAGE', 0);" eine "1" hinnein. :)
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: JoBi on January 18, 2013, 02:17:30 PM
Hab ich alles gemacht!   Funktioniert nicht!

Sollte doch auch funktionieren, wenn sagen wir mal erst in der unter-->unter-->unter--> das erste Bild drin ist, oder??

Bsp: Hauptkategorie Sport >>>>Unterkateorie Fussball >>>>>Unterkategorie Bundesliga >>>>>und jetzt erste die Kategorie mit dem Spiel z. B Bayern München gegen Schalke 04   D.h es müsste mir erst hier das erste mal ein Bild anzeigen, oder funktioniert das nur mit den Hauptkategorien???

VG
Josef
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: JoBi on January 20, 2013, 08:19:25 PM
Kann mir das vielleicht noch einer beantworten, ob das nur mit den hauptkategorien funktioniert oder auch mit den Unterkategorien

VG
Josef
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: Rembrandt on January 21, 2013, 04:43:32 AM
.Sollte doch auch funktionieren, wenn sagen wir mal erst in der unter-->unter-->unter--> das erste Bild drin ist, oder??
....
Leider nein...

mfg Andi
Title: Re: [Mod] Show Random Images from the Subcategories
Post by: JoBi on January 21, 2013, 11:05:34 AM
ahhh ok....schade,  danke dir für die info!

Mal schauen wie ich das sonst noch lösen könnte, dass es mir ein Bild zur kategorie anzeigt!