4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: alinford on February 14, 2003, 07:13:02 AM
-
Is there any way to show the image totals in each subcategory while on the main page?
-
Just copy {total_images} to the template categories.html
Jan
-
That seems to give me the total of all images, not the total next to each subcategory.
-
Ok, did not understand you correctly. But what do you mean exactly? You see the image count behind each category name.
Jan
-
I guess he wants to see the number of every subcategory that is displayed on the index page.
Like- Category (132)
- Subcategory 1 (33)
- Subcategory 2 (24)
- Subcategory 1 (14)
- and so forth [/list:u] [/list:u]
-
You are a helluvaguy, that is exactly what I am looking for.
-
Open /includes/functions.php
Find: $sub_cat_list .= "<a href=\"".$sub_url."\" class=\"subcat\">".$cat_cache[$subcat_id]['cat_name']."</a>";
Replace with: $sub_cat_list .= "<a href=\"".$sub_url."\" class=\"subcat\">".$cat_cache[$subcat_id]['cat_name']."</a> (".$cat_cache[$subcat_id]['num_images'].")";
-
Thanks!
I had messed around with this for a few days and could not get it right.
I have a family site, http://linford.net
I have 4images integrated with Geeklog and this little change was somthing I needed.
-
Hi !
Ich habe da ein Problem,
Zwar bekomme ich jetzt auf der Hauptseite die Anzahl der Bilder in den Sub-Kategorien gezeigt, aber irgendwie stimmt der Zähler nicht.
Beispiel:
Musik (55)
---- LP´s (0)
---- Singles (0)
---- DVD (33)
Hier wird (0) angezeigt obwohl z.B. 18 Bilder in der Kategorie LP´s vorhanden sind.
Irgendeine Idee woran das liegt ????
Liebe Grüße
Heiko
-
This is confusing, so you may need to read it more than once.
Is there any way that it can show the subcategory total + the total of all subcategories of the subcategory?
Somthing like this:
Category (71)
Subcategory 1 (33)
Subcategory 1.a (12)
Subcategory 1.a.1 (5) [/list:u] Subcategory 1.b (10) [/list:u]
Subcategory 2 (24)
Subcategory 2.a (24) [/list:u]
Subcategory 3 (14)
[/list:u]
What the above is showing in the () is this:
Subcategory 1 (33) = 1(11) 1.a(7) + 1.a.1(5) + 1.b(10)
Subcategory 2 (24) = 2(0) + 2.a(24)
Subcategory 3 (14) = 3(14)
What I am trying to avoid is when I have a subdirectory with 0 images, but several subsubidrectories with images. What shows up is that the subdirectory has (0) images, but you can't see the subsubdirectory totals unless you click on the subdirectory with 0 images. It gives the idea that there are no images in the subdirectory even though there are images in subsubdirectories. I don't want to show the subsubdirectories on the main page, but I do want to include the images from the subsubdirectories in the totals for the subdirectories so that they do not look empty.
-
What the above is showing in the () is this:
Subcategory 1 (33) = 1(11) 1.a(7) + 1.a.1(5) + 1.b(10)
Subcategory 2 (24) = 2(0) + 2.a(24)
Subcategory 3 (14) = 3(14)
actualy that how it works...isnt it? atleast for me.
-
On the main page it shows like this for me:
Category (71)
Subcategory 1 (11)
Subcategory 2 (0)
Subcategory 3 (14)
[/list:u]
The problem is that Subcategory 1 looks like it has (11)images. It actually has (33), (11) in 1 + (7) in 1.a and (5) in 1.a.1 + (10) in 1.b.
Subcategory 2 looks like it has (0) when it actually has (24) in subcategory 2.a.
This would be like showing the Category total , but only giving the total for images in the subdirectories and not adding in subsubdirectories because they are 2 directory levels below.
-
With the script above, I can now see num_images on index.php for each category as well as each immediate subdirectory. num_images for Category shows the total images for the category, including all subdirectories. The problem with the code above that adds num_images for the subdirectories only shows the image total for that subdirectory. I would like it to show the total for the subdirectory and any subdirectories inside that subdirectory.
Any ideas?
-
Has anyone figured this out yet? I am having the same problem. I created a subcategory and then several subcategories under that. My total for the main subcategory is 0, since all the images are in the subcategory under that. For example:
Category: Zoo Special Events (5)
Subcategory: Egg Day (5)
Subcategory: Migratory Bird Day (0)
Sub-Subcategory: Games (15)
Sub-Subcategory: Art Show (20)
This is very confusing, because only the main and subcategory show up in the main categories page, so it looks like there are no images under Migratory Bird Day, when there are actually 35. The user doesn't know to click on it and look for the subcategories since it says there are 0 images.
If this cannot be solved, is there an easy way to show more levels of subcategory on the main category list?
-
THX - Danke für diesen kleinen (little) MOD :wink: Funktioniert bei mir in der V.1.7.6 perfekt!
Working perfect in/on V1.7.6
LG euer Jasi
-
Has anyone figured this out yet? I am having the same problem. I created a subcategory and then several subcategories under that. My total for the main subcategory is 0, since all the images are in the subcategory under that. For example:
Category: Zoo Special Events (5)
Subcategory: Egg Day (5)
Subcategory: Migratory Bird Day (0)
Sub-Subcategory: Games (15)
Sub-Subcategory: Art Show (20)
This is very confusing, because only the main and subcategory show up in the main categories page, so it looks like there are no images under Migratory Bird Day, when there are actually 35. The user doesn't know to click on it and look for the subcategories since it says there are 0 images.
If this cannot be solved, is there an easy way to show more levels of subcategory on the main category list?
+++PUSH+++ :D
For the meanwhile I help me out with a trick:
REPLACE the whole $sub_cat_list Line with the following...
if ($cat_cache[$subcat_id]['num_images'] == 0) {
$anzahl = "";
}
else {
$anzahl = " (".format_text($cat_cache[$subcat_id]['num_images']).")";
}
$sub_cat_list .= "<a href=\"".$sub_url."\" class=\"subcat\">".format_text($cat_cache[$subcat_id]['cat_name'], 2)."</a>".$anzahl."";
It's not the best, but now it shows nothing, if there is really no content inside the subcategory OR if there is the 0-Bug.
Otherwise it will print out (5) for example.
-
I know this is a very old thread, but it looks like no-one has solved this issue? So I decided to share what I did to implement a way of showing counts for a category hierarchy that includes the total images in subcategories. However, I found that it increased the number of SQL statements executed per page from around 25 to over 800, thus slowing down my pages. This was for a hierarchy of 163 categories up to 4 levels deep.
It involves a recursive function that starts from the top level and for each category finds all of its children, and all of its children's children, and so on, to build up a subcategory list for each category, which is then used to query the image table to get the total hierarchy counts.
I put the recursive function in functions.php and call it from globals.php to update the cat_cache with the results. I had then to put a fix into page_header.php otherwise the total_images value will double/triple/etc count the images in subcategories.
However because of the performance hit I decided to implement this in a different way which works for my site but may not be appropriate for other sites (I use my site as a way of distributing my catwalk fashion images to publishing clients, so I am the only person who uploads images and I normally do this in bulk via ftp). I made a plugin that does the same recursive hierarchy count but stores the results in a new field added to the categories table for each category. The population of cat_cache in globals.php is now just a single query to retrieve these values. Every time I do a bulk upload I run this plugin.
HTH,
Rob