4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started 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:
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
-
Sehr schön, Danke!
-
Hi -
Found this MOD to be very intriguing. Is this MOD available to registered users to copy the images or just administrators?
Thanks,
Brian
-
admins...
-
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.
-
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.
-
... (I had to edit "includes/db_field_definitions.php instead of "includes/db_definitions.php" which doesn´t exist anymore.)
THX !
- 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
-
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,
-
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
-
...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 :)
-
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.
-
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.
-
I installed it on version 1.7.9 without any problems.
Great mod thanks.
-
...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.
-
.... other steps should not be done? Could you be more clear.
you need all steps
-
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,
-
Great Plugin working like a charm on 1.7.10.
Thanks Rembrandt
-
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.
-
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
-
Thank you for fast reply ...
But don't work for me.
-
...But don't work for me.
I've tested it again, it works...
-
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 !
-
...
: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:
<a href="{cat_url}" >
and replace:
<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
-
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:
<a href="{cat_url}" >
and replace:
<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
-
Installed & Working Perfectly 100%
Thanks
-
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
-
... 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
-
Ich habe alle Schritte nacheinander abgearbeitet
-
Welche Gesamtzahl meinst du denn?
In den Kategorien oder eben die Gesamtzahl aller Bilder zusammen?
-
Die Zahl auf der Startseite neben der Hauptkategorie
-
suche und entferne in der category_bit.html:
{num_images}
dann wird die Anzahl nicht mehr angezeigt.
-
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
-
Habe ich gemacht.
Danke euch