Avatar danny1973 asked

Display empty categories without items

How can I show empty categories? I have menulink to frontpage of cookbook and I will display all categories of cookbook, also categories without items. Thanks for help.

Regards Danny

  • Joomla
  • ZOO

Edited

15 Answers

1

Avatar danny1973 answered

Thanks for your answer. In a cookbook it make many sense. Users should be submissions for categories but this is difficult without categories. In many catalogs there are empty categories, which are displayed, to show that they exists.
Should I fill in as admin on a cookbook recipe page now once 200 categories with a prescription, so the user can see which categories are available? I want a nice category view with photos.

(It would also be nice if the user sending in contributions could select a category that does not sort the admin must always know where that belongs.)

Greets Danny

Edited

1

Avatar mustaq Yootheme answered

I see, currently Frontend Category selection is only possible for Trusted User level and at that stage they can see all Categories. If you like, you can have an Item and add it to all categories, with some sample text like Be the first to submit a Recipe in the Category

YOOgards :)

1

Avatar danny1973 answered

I like, I like :)

It would be nice for the future, if the admin gets the possibility to decide whether he can show empty categories. Thank you.

Greets Danny

Edit: I have try to edit /media/zoo/applications/cookbook/templates/default

frontpage.php, category.php, _categories.php and _category.php

I have remove if instructions like if ($this->category->childrenHaveItems()) from frontpage.php and
// remove empty categories - area from _categories.php but nothing helps :(

It was nice, if you can tell me exactly, where and what I have to edit, that empty categories are displaying. Thank you very much.

Edited

1

Avatar harald.kowalski answered

As said before: To show empty categories makes definitely sense! I purchased Zoo yesterday and I'm a little bit shocked, that it's not implemented.

1

Avatar grzegorz.laski answered

@mustaq - its needed when you have for example web directory - you need to display categories even if they are empty.

Anyway I did small trick and it works like a charm :)

I create an item with empty name and nothing inside. Then I've added item to all categories in my web directory.
When you do this, you will have all categories visible. But of course when you display number of items in category - you will have everywhere 1. It's ok, but looks not very nice :) So you have to find file _category.php in media/zoo/applications/business/templates/default - this path is for business application). Please find line:
<span>(<?php echo $category->totalItemCount() ; ?>)</span>
and replace it with
<span>(<?php echo $category->totalItemCount()-1 ; ?>)</span>

Enjoy your empty categories - this is screenshot with final effect: http://www.publikuj.to/categories.jpg

Edited

1

Avatar danny1973 answered

@mustaq Why YOOtheme has never interested in customers' needs. I do not understand. If YOOtheme thinks the show has no point, empty categories, it does not mean that customers also think it would make no sense. In any catalog or cooking book in which visitors can sign up, you can see all the categories, even empty, otherwise you would know when visitors have no idea that it is to fill in these categories and they would remain forever empty. It can not be that hard to give customers the ability to leave also show empty categories, even if it YOOtheme is absurd. Sorry I just can not understand, and I not only I wish this feature for a long time because I need it. For me it has a lot of sense, because I do not want a meaningless item in each category, except that you can see this, it is pointless for me.

@grzegorz.laski Thank you for your tip but count -1 is not okay, because I delete emty item, if category has a real entry and then is -1 in many empty categories okay but in some wrong. It is a first help solution but I still hope and a very long time, Yootheme has a heart for customers wishes :)

Greets Danny

1

Avatar webjive answered

Actually, this is pretty easy to accomplish. Just edit /media/zoo/applications/business/templates/default/_categories.php

Locate these lines of code
if ($category->totalItemCount()) {
$selected_categories[] = $category;
}
Change it to this:
//if ($category->totalItemCount()) {
$selected_categories[] = $category;
//}
And you will then see categories on the frontpage.

0

Avatar grzegorz.laski answered

@danny1973 - the trick works - but you have to add empty item to every category in your directory.
Than there where category was empty after -1 will be zero in category count, there where was more than 1 - will be number of categories decreased by 1 - in fact this will be real number of submissions.

0

Avatar danny1973 answered

add empty item to every category >

Yes but I will not add empty item add to EVERY Category. It has for me not sense, empty item :) It is for me only first solution.... but no solution for ever. Because of this I will delete empty item from categories, which get real entries.

Edited

0

Avatar justin.conn answered

Karen Vick - your solution worked like a charm. Thanks!

0

Avatar dwyndoan answered

Hi Guys..
im not sure what i did.. but it works for me at this moment
im working under "product" application

Make sure to backup your files before you make any changes.

  1. go to "media/zoo/applications/product/templates/default/" and modify 2 files ( _categories.php and _category )

  2. inside "_categories.php"
    find :
    if ($category && !$category->totalItemCount()) continue;
    replace with :
    if ($category && !$category->totalItemCount() && $category->totalItemCount() ) continue;

  3. inside "_category.php"
    find :
    if (!$child->totalItemCount() ) continue;
    replace with :
    if (!$child->totalItemCount() && $child->totalItemCount() ) continue;

  4. Then i update the zoo (category) classes "administrator/components/com_zoo/classes/category.php"
    find :
    public function childrenHaveItems() {
    foreach ($this->getChildren(true) as $child) {
    if ($child->itemCount()) {
    return true;
    }
    }
    return false;
    }
    replace with :
    public function childrenHaveItems() {
    foreach ($this->getChildren(true) as $child) {
    return true;
    }
    return false;
    }

hope this help you and Good luck!

-1

Avatar grzegorz.laski answered

Okay, I see that you don't understand, just try what I wrote. Just create an item, and add this to all categories, than correct file as I mentioned. Of course this is not solution for ever, but it works, so why not to use. But as you wish

regards

-1

Avatar karen.vick answered

Hi I would like to see this option added to Zoo (Directory) as well. This feature would allow in this case attorneys wanting to be listed in the directory to see the various Areas of law they could be listed in.

I don't really want to modify code to do what I want to. (@grzegorz.laski Thanks for the work-around)

This option is possible in another Joomla Directory component that I tested out and will not use because it is far less useful than Zoo's Directory App. See the screenshot below of the output when this option to show empty categories are enabled in this other component...

Image

-1

Avatar karen.vick answered

Hi guys. To solve this I created a type called "Empty Record" with no elements and an item of named "empty" assigned to all the categories.. If you do this don't enable comments nor make the item searchable and don't display on the front page. There is no need to edit code if you do this ;)

Now I have to manually reorder the categories alphabetically because there's no way to sort columns in the admin... For some reason even though I entered each category alphabetically they appear in the reverse?? :(

Good luck

Edited

Know someone who can answer? Share a link to this question via email or twitter.