Author Topic: [Mod] Same Image in multiple Categories  (Read 52297 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
[Mod] Same Image in multiple Categories
« on: July 18, 2010, 08:38:53 AM »
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:
Code: [Select]
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 AND i.cat_id $cat_id AND c.cat_id i.cat_id
and replace:
WHERE i.image_active 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_id01);
    }

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
« Last Edit: July 18, 2012, 05:53:27 PM by Rembrandt »

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.808
  • I ♥ 4I
    • View Profile
Re: [Mod] Same Image in multiple Categories
« Reply #1 on: July 18, 2010, 10:19:17 AM »
Sehr schön, Danke!

Offline surferboy

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: [Mod] Same Image in multiple Categories
« Reply #2 on: September 14, 2010, 05:38:29 AM »
Hi -

Found this MOD to be very intriguing.  Is this MOD available to registered users to copy the images or just administrators?

Thanks,

Brian

Rembrandt

  • Guest
Re: [Mod] Same Image in multiple Categories
« Reply #3 on: September 14, 2010, 06:17:48 AM »
admins...

Offline ccsakuweb

  • Sr. Member
  • ****
  • Posts: 498
  • Patri
    • View Profile
    • My Art
Re: [Mod] Same Image in multiple Categories
« Reply #4 on: September 18, 2010, 12:53:43 PM »
If you have lots of images in differents categories, it will be really heavy, dont you think the same?
But I think that it would be great have an image in several categories.
:arrow: 4images Paid Mods: Links, Blog, Albums, Subdomains for users, Diferent templates for user profile, Related picture in details, Last pictures in details.
And the mod that you request me.   Demo: http://www.myart.es

A website dedicated to artist people who loves drawing, design, writing and more

Offline Tiburon

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • http://www.hintergrundbilder.de
Re: [Mod] Same Image in multiple Categories
« Reply #5 on: September 20, 2010, 12:21:26 PM »
First of all, thank you for this MOD. Great work.

I installed it to a local installation of version 1.7.8 and as far as I can see it works fine (I had to edit "includes/db_field_definitions.php instead of "includes/db_definitions.php" which doesn´t exist anymore.)

There is only a little error in it.

Example:

- an image is uploaded to category 1 and then added to category 2
- if there are already images in category 2 everything works fine
- if there are no images in category 2 the category name is changed to category 1 if you list the category

It doesn´t really bother but there might be a simple solution to fix this little error.
« Last Edit: September 20, 2010, 02:38:48 PM by Tiburon »
----------------------------------

Have a nice Day

Rembrandt

  • Guest
Re: [Mod] Same Image in multiple Categories
« Reply #6 on: September 20, 2010, 06:13:35 PM »
... (I had to edit "includes/db_field_definitions.php instead of "includes/db_definitions.php" which doesn´t exist anymore.)
THX !

Quote
- if there are no images in category 2 the category name is changed to category 1 if you list the category
mean you the category name below the thumbnails?
this is not a bug this is a feature.

ahh,.. ok understand now....
...at the moment I have no solution for it

mfg Andi

Offline nephot

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [Mod] Same Image in multiple Categories
« Reply #7 on: April 03, 2011, 04:10:30 PM »
Hi,

Thanks for this mod.
I'd like to know certain details about the mod, as I couldn't figure it out from the code (I don't know programming).
Assigning multiple categories will make multiple copies of the same image, or will it make links in multiple categories?
I think it is the second case, then it is really useful, to save a lot of disk space/redundancy.
So, I'd like to know if this makes links or copies?

Thanks,

Rembrandt

  • Guest
Re: [Mod] Same Image in multiple Categories
« Reply #8 on: April 03, 2011, 05:28:22 PM »
Wellcome to the Forum!
.... or will it make links in multiple categories?
I think it is the second case, ....
yes only one entry in the database.

mfg Andi

Rembrandt

  • Guest
Re: [Mod] Same Image in multiple Categories
« Reply #9 on: April 21, 2011, 08:46:07 AM »
...There is only a little error in it.
...- an image is uploaded to category 1 and then added to category 2
- if there are already images in category 2 everything works fine
- if there are no images in category 2 the category name is changed to category 1 if you list the category
...

i have fixed this.
Please repeat step 4.) and 4.4) and add the new step 4.5)

I hope that was it  :)

Offline nephot

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [Mod] Same Image in multiple Categories
« Reply #10 on: May 01, 2011, 11:35:17 AM »
Thank you very much for this mod. It works excellent.

It allows to assign multiple categories for images one by one.
A desirable additional feature would be to be able to select multiple images and assign them to additional categories.

Either this mod can be incorporated into the search results of the "Edit Image" link,
or just on the main page of image browsing, so that multiple images at a time can be selected and assigned to additional categories.

On by one assignment, is really tedious for someone having 100's/1000's of images.

Thank you for the mod.

Offline khansahib

  • Full Member
  • ***
  • Posts: 100
    • View Profile
Re: [Mod] Same Image in multiple Categories
« Reply #11 on: May 27, 2011, 03:31:02 AM »
its a very nice MOD, thanks for that.. and i would love to have wt "nephot" mentioned.. please think abt it, as it gets very difficult to assign category ids for large number of images.. Hope you'll come up with a solution.. :)
Thanks.

Offline wallpapers

  • Full Member
  • ***
  • Posts: 107
    • View Profile
    • Tuned-Cars.Net
Re: [Mod] Same Image in multiple Categories
« Reply #12 on: August 27, 2011, 07:39:44 PM »
I installed it on version 1.7.9 without any problems.

Great mod thanks.



Offline nephot

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [Mod] Same Image in multiple Categories
« Reply #13 on: October 02, 2011, 09:27:32 AM »
...There is only a little error in it.
...- an image is uploaded to category 1 and then added to category 2
- if there are already images in category 2 everything works fine
- if there are no images in category 2 the category name is changed to category 1 if you list the category
...

i have fixed this.
Please repeat step 4.) and 4.4) and add the new step 4.5)

I hope that was it  :)

I was trying to add the multiple category functionality. I too have the same problem. Images cant be added to empty categories.
I haven't clearly understood the above instruction. Only the steps 4.) 4.4) and 4.5) need to be done? So, other steps should not be done? Could you be more clear.

Rembrandt

  • Guest
Re: [Mod] Same Image in multiple Categories
« Reply #14 on: October 02, 2011, 09:33:37 AM »
.... other steps should not be done? Could you be more clear.
you need all steps