4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Rembrandt on July 18, 2010, 08:38:53 AM

Title: [Mod] Same Image in multiple Categories
Post by: Rembrandt 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 = 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
Title: Re: [Mod] Same Image in multiple Categories
Post by: Sunny C. on July 18, 2010, 10:19:17 AM
Sehr schön, Danke!
Title: Re: [Mod] Same Image in multiple Categories
Post by: surferboy 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
Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt on September 14, 2010, 06:17:48 AM
admins...
Title: Re: [Mod] Same Image in multiple Categories
Post by: ccsakuweb 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.
Title: Re: [Mod] Same Image in multiple Categories
Post by: Tiburon 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.
Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt 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
Title: Re: [Mod] Same Image in multiple Categories
Post by: nephot 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,
Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt 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
Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt 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  :)
Title: Re: [Mod] Same Image in multiple Categories
Post by: nephot 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.
Title: Re: [Mod] Same Image in multiple Categories
Post by: khansahib 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.
Title: Re: [Mod] Same Image in multiple Categories
Post by: wallpapers on August 27, 2011, 07:39:44 PM
I installed it on version 1.7.9 without any problems.

Great mod thanks.
Title: Re: [Mod] Same Image in multiple Categories
Post by: nephot 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.
Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt on October 02, 2011, 09:33:37 AM
.... other steps should not be done? Could you be more clear.
you need all steps
Title: Permission Problems: Same Image in multiple Categories
Post by: nephot on October 05, 2011, 06:49:43 AM
I could implement this mod and seems very useful. However, I found that the concept fails to address a specific senario.
On my 4images site, I made categories for each year. like 2008, 2009 etc.
Now  I don't want guests to see all images in 2009, so for them I made another category 2009G.
Using multiple categories mod, I assigned selected 2009 images to 2009G. Thus 2009G just have links to some 2009 images.
Now I set permissions as private for 2009 and as Registered Users for 2009G.
With this the image thumbnails are visible in 2009G but they can't be clicked to open. I thought this might be because of private permissions on 2009. So I gave all except view category on 2009, because I don't want 2009 to be visible to them. But still this is not working. The only way images in 2009G could be viewed is by giving view category permission on 2009, but this defeats the purpose of what I intended to do.

Is there any way to achieve what I wanted.
Thanks,
Title: Re: [Mod] Same Image in multiple Categories
Post by: yousaf on March 06, 2012, 02:45:20 PM
Great Plugin working like a charm on 1.7.10.
Thanks Rembrandt
Title: Re: [Mod] Same Image in multiple Categories
Post by: benef4u on July 18, 2012, 01:24:41 PM
Great Work fine for me !
Thank you !
but counter on second category is not updated.

example : I upload an image on category A ( show category counter  = 1) but when i edit image and add an another category (B) counter on category stay at 0

if someone can help me.

Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt on July 18, 2012, 05:56:26 PM
Welcome to the Forum!
...but counter on second category is not updated.
...
Thanks for the hint!

i have added Step.6) in my first post.
I hope it works now. :)

mfg Andi
Title: Re: [Mod] Same Image in multiple Categories
Post by: benef4u on July 18, 2012, 10:58:59 PM
Thank you for fast reply ...
But don't work for me.

Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt on July 19, 2012, 07:03:48 AM
...But don't work for me.
I've tested it again, it works...
Title: Re: [Mod] Same Image in multiple Categories
Post by: benef4u on July 19, 2012, 08:32:10 AM
50% working  :lol:
count is working on subcategory, not on root category.

Some little things perhaps in the future :

 :arrow: Only image A is indexed (for search and statistics(total images))

 :arrow: Name of  CAT_ID is only show on admin/categories.php (name id=1)  and its hard to know which category corresponding at Cat_ID;


congratulations for your patience and rapidity !
Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt on July 19, 2012, 12:08:48 PM
...
 :arrow: Name of  CAT_ID is only show on admin/categories.php (name id=1)  and its hard to know which category corresponding at Cat_ID;
....

fast fix :) :
search in your thumbnail_bit.html:
Code: [Select]
<a href="{cat_url}" >
and replace:
Code: [Select]
<a href="{cat_url}" title="{cat_id}">

on mouseover can you see the Cat ID, or see below on Browser Status row.

is this what you want?
mfg Andi
Title: Re: [Mod] Same Image in multiple Categories
Post by: benef4u on July 19, 2012, 01:07:18 PM
sorry for my bad english

Multicount works for sub category, but not for parent category

Example :

Animals (0)  -- dogs (2)
                  -- cats (1)


                
...
 :arrow: Name of  CAT_ID is only show on admin/categories.php (name id=1)  and its hard to know which category corresponding at Cat_ID;
....

fast fix :) :
search in your thumbnail_bit.html:
Code: [Select]
<a href="{cat_url}" >
and replace:
Code: [Select]
<a href="{cat_url}" title="{cat_id}">

on mouseover can you see the Cat ID, or see below on Browser Status row.

is this what you want?
mfg Andi

ok for me thanks
Title: Re: [Mod] Same Image in multiple Categories
Post by: chamkani.net on October 23, 2012, 10:15:03 AM
Installed & Working Perfectly 100%

Thanks
Title: Re: [Mod] Same Image in multiple Categories
Post by: marcusfuerth on August 15, 2014, 03:15:32 PM
Habe nochmal eine Frage zu dem Mod.
Er funktioniert einwandfrei. Jedoch werden die Bilder nur in der Kategorie in der sie tatsächlich sind, als Bilder in der Gesamtanzahl addiert. In den verknüpften Kategorien nicht.
Kann man das noch iwie ändern?

Und die andere Frage wäre dann noch, ob man den Mod vielleicht so modifizieren kann, dass man bei vielen Bildern >20 einmal oben eingibt, in welchen Kategorien die Bilder verknüpft werden sollen.

Beziehungsweise; vielleicht kann man diese Bilderanzahl komplett ausblenden

Danke
Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt on August 15, 2014, 05:29:56 PM
... Jedoch werden die Bilder nur in der Kategorie in der sie tatsächlich sind, als Bilder in der Gesamtanzahl addiert. In den verknüpften Kategorien nicht.
...
Dann fehlt dir Schritt 4.) u. 4.1)

mfg Andi
Title: Re: [Mod] Same Image in multiple Categories
Post by: marcusfuerth on August 18, 2014, 12:48:45 PM
Ich habe alle Schritte nacheinander abgearbeitet
Title: Re: [Mod] Same Image in multiple Categories
Post by: senloel on August 18, 2014, 01:09:16 PM
Welche Gesamtzahl meinst du denn?
In den Kategorien oder eben die Gesamtzahl aller Bilder zusammen?
Title: Re: [Mod] Same Image in multiple Categories
Post by: marcusfuerth on August 18, 2014, 02:07:50 PM
Die Zahl auf der Startseite neben der Hauptkategorie
Title: Re: [Mod] Same Image in multiple Categories
Post by: Rembrandt on August 18, 2014, 03:10:39 PM
suche und entferne in der category_bit.html:
Code: [Select]
{num_images}
dann wird die Anzahl nicht mehr angezeigt.
Title: Re: [Mod] Same Image in multiple Categories
Post by: nobby on August 18, 2014, 03:28:26 PM
Hi,

nichts für ungut @Rembrandt aber, auskommentieren ist immer der bessere Weg  :wink:

Auskommentiert wird so <!-- {num_images} --> .

Das hat den vorteil weils schnell wieder rückgängig zu machen ist :)



nobby
Title: Re: [Mod] Same Image in multiple Categories
Post by: marcusfuerth on August 21, 2014, 07:15:41 PM
Habe ich gemacht.

Danke euch