Keyword

hide items in sub-category view

  • Janmeir Digon
  • Janmeir Digon's Avatar Topic Author
  • Offline
  • New Member
More
11 years 11 months ago #106008 by Janmeir Digon
hide items in sub-category view was created by Janmeir Digon
Hi There!

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 to one of the forums here. My category structure is like this:

Category
sub-Category
Items

I was hoping that you can show me how to hide the items under my subcategory when users are in sub-category view and will only be shown if the user clicks on the subcategory folder ( I hope I make sense). To illustrate, I was hoping it would look like this:

Category
sub-Category

and when sub-Category is clicked, then it would look like this:

sub-Category
Item 1
Item 2
Item 3
Item 4

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 mentioned in one of the K2 forums, that is, 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 the case of the moderator who answered in that forum.

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.

More
11 years 11 months ago #106009 by Gregwh
Replied by Gregwh on topic Re: hide items in sub-category view
I may have you wrong so please have a look at the link below:

www.sell-my-books.com/index.php/books

When you go to the main menu of that site, you get a link to Books for people to read. When you click on that link you get subcategories that are available for people to go to, those being genres of books. The individual items in categories (and this is a new site so only has one thing in Fantasy so far) dont show until the site visitor actually goes into a particular genre. Under that genre, there are listings for what is available to read and they dont show what is inside the item until clicked upon. The way the site is set up, the first chapter of any book is free for anyone to read and the rest of the book is pay to read based upon whatever price the author wants for the book. So, with that one item in Fantasy, you can read the first chapter as a viewer but cannot read the second until you create an account and even then cannot read it unless you pay for the right to do so. Once payment is completed (PayPal only), you get to view whatever you have paid to read for the life of your account on the site. If you dont use the account within a calendar year, your account is deleted and you would have to pay to read once more.

So, can you go there, check that out and tell me if that is what you are attempting please? If so then I should be able to help.

Greg.

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

  • Janmeir Digon
  • Janmeir Digon's Avatar Topic Author
  • Offline
  • New Member
More
11 years 11 months ago #106010 by Janmeir Digon
Replied by Janmeir Digon on topic Re: hide items in sub-category view
Hi Greg! Thank you very much for replying to my post. Thank you also for the link - I'm very much impressed with what you have there in your website. :)

Yes, you got it right. I wanted visitors to first click on the sub-category and enter it before they get to the item that such sub-category contained. It's like having a particular file inside a sub-folder where the only way to get access to such file is to click on and enter the sub-folder. My main problem with K2, as you have correctly understood, is that it keeps on displaying the items below the sub-category blocks and shows the items, along with the sub-category blocks, to visitors when they click on the main category. I have tried tweaking the setting options on the back-end but it seems like I might have to do a hack somewhere - problem is, I don't know where. :(

I like the category structure you have in place in your website. Visitors are not able to view the contents of the sub-category unless they click on that particular sub-category.

Thank you very much for your offer to help. I hope you wouldn't mind if I take you up on your offer. May you be kind enough to help me please? I would really appreciate it very much if you can help me out. Once again, thank you so very much! :)

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

More
11 years 11 months ago #106011 by Gregwh
Replied by Gregwh on topic Re: hide items in sub-category view

Janmeir Digon wrote: Hi Greg! Thank you very much for replying to my post. Thank you also for the link - I'm very much impressed with what you have there in your website. :)

Yes, you got it right. I wanted visitors to first click on the sub-category and enter it before they get to the item that such sub-category contained. It's like having a particular file inside a sub-folder where the only way to get access to such file is to click on and enter the sub-folder. My main problem with K2, as you have correctly understood, is that it keeps on displaying the items below the sub-category blocks and shows the items, along with the sub-category blocks, to visitors when they click on the main category. I have tried tweaking the setting options on the back-end but it seems like I might have to do a hack somewhere - problem is, I don't know where. :(

I like the category structure you have in place in your website. Visitors are not able to view the contents of the sub-category unless they click on that particular sub-category.

Thank you very much for your offer to help. I hope you wouldn't mind if I take you up on your offer. May you be kind enough to help me please? I would really appreciate it very much if you can help me out. Once again, thank you so very much! :)



Glad you like it! I kept retweaking it every single day for quite some time. Before I get into the explanation, one thing I wanted to point out about www.sell-my-books.com which is different from other Joomla or K2 sites I have done is that the front page is a different and separate Joomla template to the rest of the site which is all yet another Joomla template. Easy to set up of course but for someone reading this, it may clear up confusion.

Anyway, the answer is simple enough. Let's assume you created everything you wanted in Joomla then applied K2 to it and hit the import button. What you need to do within K2 is to first create categories (remember the old Joomla or K2 principle of C.A.M. which is Categories, Articles, Menus) that you have to create in that order for things to show up normally. No category first and the rest dont work straight away. So, create the top level category. I called the top level category, on that site "Options" but I never created a menu for it so it never actually shows up on the site. Under that create the category that corresponds to the button you want to have clicked on the front page of your site that will lead to the sub categories. In my site's case that is the BOOKS button on the front page that leads to a page showing just the genres of books to be read. Make this one a child of the OPTIONS category. There are lots of options to set in here but the primary one, at this point is in "Other Layout Options" on the right side down a little. Set "Catalog Mode" to YES. The Category Item Layout" to be chosen depends on your design preference. I left it set to "Use Default" and chose to make two Joomla templates to cover what I wanted and assign how that looks under Joomla's template manager. You need to adjust things in the "Item View Options in Category Listing" section so that hits and so on dont show at this level. You want to hide all the things you dont want shown under there at this moment. There are other options all along there in other parts of this area that really are up to you and what you want to design but DO take into account that you should ALWAYS "HIDE" the EMAIL option where on K2 or Joomla, someone can email the page to someone else. If you dont, spambots get onto it and start making your site a SORBS listing and you wont be found on internet, then.

This next is a setup that only needs to be copied once, in a way. I am a science fiction nut so I made up the Science Fiction category next but any category you make, now will be the ones that will be clicked on to go into that category and view the items within. Remember to order them in the order that suits you. In my case, all that come from here on in category in K2 are children of Books so whatever your level above this next section name is, then the categories you make up, here, are ALL children of that one up from here. Being a science fiction nut, I made that one up first and adjusted the order later. I changed "Other Layout Options" in "Catalog mode" to YES. I set Hide on Featured items and Item Ordering as Most Popular then SHOW for Pagination and Pagination Results. In Sub Category Handling, I have everything as SHOW excepting sub-category image which I set to hide. I left all of Item Image Options blank. In Item View in Category Listings, I set everything to SHOW excepting "Featured notice", "Introtext", "Attachments", "Attachments counter", "media autoplay" and "item modified time and date". I also ALWAYS have "enable K2 plugins" set to YES on this site as I may need that feature later on.
In "Item View Options", everthing is set to SHOW excepting "Email button" and "Media Autoplay". I have the Social Sharing bit just under that all set to SHOW and under Author Options I have everying set to SHOW excepting Author Email and Latest items from Author simply because I dont want people to be able to privately email the author, annoying them and I did have the latest items ON but it made the site a litle confusing to read. The latest items from an author can be set to another page and I did that in the "Author Wall and comments" on the site. All "Related items" are set to HIDE excepting "related items (by tag)" and "Related item title".

Once you save that, you have to go back and make a new category for anything else on the site BUT for the NEW categories, when you get the page up to make the new category, there is an option called "inherit parameter options from category" on the top left. If you set that one to the name of the first one you made at this level - in my case Science Fiction - you dont have to go making those changes ever again and if you DO want to make a change in future, you only ever have to make it to the one category and then all other categories instantly reflect that change. That is why i said it is like a copy.

At this point make a test K2 "item" for each of those categories so you can check it out live.

Now, I assume that you have made up a menu name such as "Main Menu" here as comes with a fresh Joomla installation. Whatever the name of your menu at this point, go there and click to add a new menu. This first menu is the top level one that corresponds to the button you want clicked that will show all the sub categories from your site. For clarification of that, go to www.sell-my-books.com and look at the BOOKS button. This is where we are right now. This button has the parent of menu item root and I changed ordering, on my site, to "Books" underneath. The TYPE of the menu when you click on SELECT is under K2 and is CATEGORIES. Once that shows up, under BASIC OPTIONS you have to select a category so select the same as the menu name you are making up now. In my case that is BOOKS. In Layout Options is only the option of "Item Ordering". This is really a design one but I chose the option "Ordering" there. Save this but make sure it is accessible as a PUBLIC menu and that it is PUBLISHED or it doesnt work.

The rest of the menus under here are all a child of the one in the previous paragraph so in my case they are all children of BOOKS and every single one of them is UNPUBLISHED. You click on New and in Select go to the K2 block and click on "Latest items from(one or more) users or categories". Remember, these are all UNPUBLISHED, all children of the menu you made in the last paragraph (for me that is BOOKS). Once you are ready with that, I chose, under BASIC OPTIONS to leave "select a template" untouched and under that for CONTENT SOURCE I set "Choose content source" to Categories and my "number of columns" is 2 and "Maximum number of items per user or category" is currently 3 but it is only a new site and I know I will have to up that, later. Under that is also "Item view options (set below) effect..." and I set that to "effect the first item only, subsequent items display title only" but that is really again a design issue and you may want it to look different. Under USER SETTINGS I chose to set everything to HIDE excepting "name" and "RSS feed icon". There is an option there to "click to select one or more users" which I didnt do because it would limit the category only to those users mentioned and if I have 10 new users today and 1000 tomorrow, I wouldnt have time to eat any longer! So ignore that option. Under CATEGORY SETTINGS is a similar option to "Click to select one or more categories" and you DO want to do this. Whatever the name of the menu that you are currently setting up is, you need to now click the same CATEGORY name and add it there. If you do this, whoever it is that posts in this category doesnt matter but this menu will ONLY show stuff posted in that particular category and no other. However, if you want it to show postings from MORE than one category then you need to add the other ones, here. So, for the menu FANTASY, I added the category FANTASY so only they show up. I set every other option in CATEGORY SETTINGS to SHOW. Under ITEM VIEW OPTIONS (COMMON FOR USER OR CATEGORY SOURCE) I set the first 4 to SHOW and the "image size" to MEDIUM then set Video to SHOW without restricting height and width then set MEDIA AUTOPLAY, INTROTEXT and CATEGORY to HIDE, TAGS to SHOW and the rest to HIDE. In ADVANCED, both options are used.

That should be it. Once you have repeated making up each menu name you want and associating it with the exact same category in the way I have explained, you should be able to go live to your site and see the test stuff you already made up but only one per category if that is all you did.

I assume you know how to enable front end editing for K2 and allow the right user level access to that while denying it to PUBLIC (if that is what you want) etc. If not, let me know.

Oh and it wasnt as easy as it sounds. It took me some time to figure this out. I employed the "Fargo from the TV series called EUREKA" principle in finding out. Eg, if I saw an option, I tried it or turned it off to see what would happen! ;-}

Let me know how you go. If it doesnt work, then send me your email address from the Sell My Books site contact form and we can work out how I can get into your admin to set up a sample for you to check out and duplicate.

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

More
11 years 10 months ago #106012 by Marcos Benites
Replied by Marcos Benites on topic Re: hide items in sub-category view
In my case I don't want the sub-category words appear only the items, how can I do this?

Tks

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


Powered by Kunena Forum