Keyword

Category View - Keep listings of subcategories separate?

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 11 months ago #86333 by Justin Herrin
Hello all,I'm trying to get K2 (or a custom template) to display a single page with the subcategories and their individual items listed separated out. Example...Page Title - Parent Category title- Subcategory 1 title-- Subcategory 1 Item 1-- Subcategory 1 Item 2- Subcategory 2 title-- Subcategory 2 Item 1-- Subcategory 2 Item 2Anyone know how to make this work? I don't mind creating a custom template, I just can't figure out what the coding would be...

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

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 10 months ago #86334 by Justin Herrin
Can anyone help with this?

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

More
14 years 10 months ago #86335 by sebix
I m trying too ..

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

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 10 months ago #86336 by Justin Herrin
I have been playing my own template, and I'm almost there, but it still needs that final bit of code that I can't figure out.

What I have displays my page like this...

Page Title - Parent Category title
- Subcategory 1 title
-- Subcategory 1 Item 1
-- Subcategory 1 Item 2
-- Subcategory 2 Item 1
-- Subcategory 2 Item 2

- Subcategory 2 title
-- Subcategory 1 Item 1
-- Subcategory 1 Item 2
-- Subcategory 2 Item 1
-- Subcategory 2 Item 2


As you can see, ALL items are showing under each subcategory, instead of just that specific subcategory's items. A bit frustrating so say the least.

Does anyone have any ideas for a fix?

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

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 10 months ago #86337 by Justin Herrin
bump. Can anyone help with this?

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

More
14 years 8 months ago #86338 by Aaron McQueen
Justin Herrin said:bump. Can anyone help with this?


I have an answer. Is there anyway to post code on here?

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

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 8 months ago #86339 by Justin Herrin
Hello Aaron - you can just attach a .txt file with the code (using the Upload a File button) or try to copy/paste into the editor.

Thanks in advance!

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

More
14 years 8 months ago #86340 by Aaron McQueen
Ok, here is what I did. I couldn't find a way to find the children of category, so I looped through all the categories and then looped through every item and checked to see if it was in the category. Attached is the code for category.php and category_item.php. This may be slow, and I haven't tried it with a large number of items. My guess is that it will fine.

Warning: create a new teamplate, do not overwrite the default. These are very stripped down versions of the templates, with a lot of features disabled, but in my case I don't what the user to have all of the options. They just need to add new items and they show up on the page.

Here is the example: umdphysics.umd.edu/white-pages-new
Attachments:

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

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 8 months ago #86341 by Justin Herrin
Hello Aaron - Thanks for providing your code, this is exactly what I was needing!

I have tested it with my categories and all is working well in my development area. My production site will have roughly 50 items spread throughout 6 subcategories, so hopefully speed is not an issue.

Thanks again, it's much appreciated!

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

More
14 years 8 months ago #86342 by Aaron McQueen
Glad I could help. It would have really helped me if there was documentation on the K2 objects and their properties. From the template I had to print out the object contents to find the correct properties I needed to make the loop. I really like K2 but the documentation is lacking.

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

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 7 months ago #86343 by Justin Herrin
Thanks again Aaron. Your code has worked well on the live site which loops through 35 items in 6 sub-categories.

www.manchestercommunitycollege.edu/business/non-credit-course-schedule

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

More
14 years 5 months ago #86344 by Cem Aslan
Hi Aaron, thanks for the code. I have replaced the entire code in the templates category.php and category_item.php with your code, but I am only seeing a list of subcategories without any items underneath. with the default code i can see the subcategories and the all the item at the bottom as normal when I change over category_item.php to your code items dissapear. I have noticed you used extra field value, do i need to set same extra field values on all, please explain. Thanks again for the great help.

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

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 2 months ago #86345 by Justin Herrin
Hello Cem and Paul - if you use the code that Aaron posted exactly as it is, you will not see any items being displayed because his category_item.php code searches and displays only items that have Extra Fields attached to them. If your items do not have Extra Fields then they will not show up.

 

Paul - you would need to make sure the category_item.php code contains the code required to display the item images. Again the code that Aaron posted does not include references to the item images.

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

  • Justin Herrin
  • Justin Herrin's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 2 months ago #86346 by Justin Herrin
I did not use images in the loop I made from Aaron's code. The page I created with it simply displayed the Category Title, then all the Items below that (Item Title, Description, Extra Fields). Then the loop was run through for all the child categories and their items.

 

Here is the page: www.manchestercommunitycollege.edu/business/non-credit-course-schedule

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

More
11 years 4 months ago #86347 by behzad
hi
how can we do this for the selectbox list of category in front-end form of sending articles?
I explain it here : stackoverflow.com/questions/21649486/cascading-dropdown-for-k2-categories-in-administrator-panel

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


Powered by Kunena Forum