Keyword

Hide sub category items?

  • Michael Tull
  • Michael Tull's Avatar Topic Author
  • Offline
  • New Member
More
13 years 7 months ago #95002 by Michael Tull
Hide sub category items? was created by Michael Tull
Hi There,

 

Firstly, let me say that I have been using K2 for a while now, love it and thought I have worked out most things (general stuff anyway), but today I came up with something that I just could not work out...

 

I want to display a category view/list of items, but ONLY display the items from the primary category in the list? (Or Sub category blocks)  I really feel like I am missing something here, so if I am asking a silly question Im sorry :) .. but I just cant find an option.  I can turn off the sub category block, I still get the sub category items?

 

Any thoughts / pointers etc would be greatly appreciated.

 

Cheers

 

Michael

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #95003 by william white
Replied by william white on topic Hide sub category items?
I have a category.php that will suppress the items from showing when subcategories exist

Category structure is

Store

     StoreCat1

            item

            item

      StoreCat2

            item

            item

In the category php just above the itemlist block i added if(!(count($this-->subCategories)));

and at the end of category.php file add endif

When i show a category view of Store i get only the two subcategories and their images and a readmore (no items show) unless you drill into the subcategory.

This may not be exactly what your looking for but may be helpfull.

thanks to Olivier for help with this code

Please Log in or Create an account to join the conversation.

  • Michael Tull
  • Michael Tull's Avatar Topic Author
  • Offline
  • New Member
More
13 years 7 months ago #95004 by Michael Tull
Replied by Michael Tull on topic Hide sub category items?
Thank you William, that does certainly help.  I thought I was just missing an 'options' somewhere, but I am set up with custom templates for each cat, so I can jump in there and look at the php and I'm sure I can work it out. ( despite my lack on php knowledge : )  I had though of that general direction, but didnt want to go that way if there was a simple "show/hide sub cat items" switch somehwere that I was just missing.

 

Thanks again.

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #95005 by Janmeir Digon
Replied by Janmeir Digon on topic Re: Hide sub category items?
Hi William!

First off, I would just like to say that K2 is an amazing component and has helped me a lot in organizing my categories, sub-categories and items in a more meaningful manner.

Recently, however, I stumbled upon an issue which I hope you can help me resolve. I have searched the web for a solution of this issue and one of the links pointed me here. I too have the same category structure like yours and I would also want the items under my subcategory to be hidden from sub-category view and will only be shown if the user clicks on the subcategory folder ( I hope I make sense).

My php knowledge is very minimal, so I am hoping to learn in plain language how to resolve this issue. I tried implementing the solution you mentioned by putting the if(!(count($this-->subCategories))); in /components/com_k2/templates/default/category.php, or more specifically, here:
<!-- Blocks for current category and subcategories -->
<?php if(!(count($this--&gt;subCategories))); ?>
<div class="itemListCategoriesBlock">

and I also placed <?php endif; ?> somewhere down the code block, but that didn't work.

I'm sure I am doing it the wrong way or not putting it in the right place since it has worked in your case.

So if you would be kind enough to spare a bit of time, can you please help me with this? I would very much appreciate it.

I have also included a screenshot of my frontend to illustrate the issue.

I hope you can help me out and point me in the right direction and tell me what code to insert. Thank you very much for reading this post! :)
Attachments:

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum