Keyword

How to create categories list with image and description?

  • Panagiotis
  • Panagiotis's Avatar Topic Author
  • Offline
  • New Member
More
7 years 6 months ago - 7 years 6 months ago #157944 by Panagiotis
Hi everybody.
I want to create a list of categories with k2 extension which will display the category 's title, the image and the description.
Something like this:
File Attachment:


How can I do it?
Last edit: 7 years 6 months ago by Panagiotis.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 6 months ago #157973 by Krikor Boghossian
Replied by Krikor Boghossian on topic How to create categories list with image and description?
Hello,

If these are subcategories, you can use the subcategories block to display this data. Eg: demo.nuevvo.com/sites/j3x/takai/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=14&Itemid=158

Otherwise you can use the latest items from categories menu item, and not display any items.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Panagiotis
  • Panagiotis's Avatar Topic Author
  • Offline
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #158685 by Panagiotis
I 'm replying with some delay, sorry for this.

I try to make a Menu Item with Menu Item Type = Categories (K2 Categories).

In the menu item 's Options, in 'Select categories', I put a category and saved it.
But when I click on the menu item in my site, an error (actually a notice) occurs:

Notice: Trying to get property of non-object in ....\components\com_k2\views\itemlist\view.html.php on line 651


Line 651 is this:
if (!is_null($active) && $active->id == $default->id && $sef)

Using:
var_dump($default)
I get: null.

For some reason line 640:
$default = $menu->getDefault();
returns null.

My menu item is the default item of the menu, it is the home.



Last edit: 7 years 5 months ago by Panagiotis.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 5 months ago #158694 by Krikor Boghossian
Replied by Krikor Boghossian on topic How to create categories list with image and description?
Which version of K2 are you using?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Panagiotis
  • Panagiotis's Avatar Topic Author
  • Offline
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #158695 by Panagiotis
I use 2.7.1 (K2_v2.7.1.zip) (on Joomla 3.6.2).
Last edit: 7 years 5 months ago by Panagiotis.

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

  • Panagiotis
  • Panagiotis's Avatar Topic Author
  • Offline
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #158697 by Panagiotis
I also found out something not so..pleasant.
K2 catalogue can show only one K2 category.

I have 2 main categories, Products and Services.
I have put for both of them at Display settings->Other layout options->Catalogue mode=true.
Each of them has subcategories:

Products:
--Carpets
--Flooring
--Furniture

Services:
--Custom made
--Cleaning


1. In my Menu item 'Home': in Options->Select categories I put 'Products' .
My Home 's menu item's url: option=com_k2&view=itemlist&layout=category&task=category&id=20
Works ok, (except the above mentioned Notice), shows:
Carpets
Flooring
Furniture

2. In my Menu item 'Home': in Options->Select categories I put 2 categories, Products and Services.
My Home 's menu item's url: option=com_k2&view=itemlist&layout=category&task=&Itemid...
Doesn't look good to me, the link has no task and no category id while I have selected 2 categories.

And of course the result is as expected, no category is shown...
The result is an empty page.
Last edit: 7 years 5 months ago by Panagiotis.

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

  • Panagiotis
  • Panagiotis's Avatar Topic Author
  • Offline
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #158715 by Panagiotis
In {site path}\components\com_k2\views\itemlist\view.html.php, line 34:
// Get data depending on task
		switch ($task)
		{

			case 'category' :
				// Get category
				$id = JRequest::getInt('id');

From what I understand, id can't be an array, it can only be an integer.
So a menu item can't really point towards multiple K2 categories (in Menu Item 's Options->Select Categories).
It can only point to one.
Am I right?
Last edit: 7 years 5 months ago by Panagiotis.

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

  • Panagiotis
  • Panagiotis's Avatar Topic Author
  • Offline
  • New Member
More
7 years 5 months ago - 7 years 5 months ago #158724 by Panagiotis
In file {site}\components\com_k2\views\itemlist\view.html.php,
I changed lines 640 & 641 from:
		$default = $menu->getDefault();
		$active = $menu->getActive();
...to:
		$active = $menu->getActive();
		$default = $menu->getDefault($active->language);
...and the Notice (mentioned in #158685) is gone...
Last edit: 7 years 5 months ago by Panagiotis.

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


Powered by Kunena Forum