Category display

  • Posts: 237
  • Thank you received: 13
1 week 3 days ago #372955

-- HikaShop version -- : 6.5.2
-- Joomla version -- : 6.1.2
-- PHP version -- : 8.3

I have a simple need, i want to have a module to display some categories based on my own selection.
isn't it possible in HikaShop ?

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

  • Posts: 86042
  • Thank you received: 14174
  • MODERATOR
1 week 3 days ago #372957

Hi,

The HikaShop module (Type of content: Categories) lists the sub-categories of one main category you pick. So it can only show categories that share the same parent, it has no option to hand-pick categories from different branches of your tree.

To get your own selection you have two ways:

1) Bring them under one parent. Create a category to act as the container, then change the parent of each category you want to feature so they sit under it (drag and drop in the Categories page, or set the parent in each category's edit form). This does not move or unlink your products, they stay in their categories. Then point the module at that container and it lists exactly your selection. This gives you the normal HikaShop category tiles with images.

2) Leave the categories where they are and build the list by hand. Add a Joomla "Custom" (Custom HTML) module and put a link, and an image if you want, to each chosen category in it. More manual, but nothing in your category tree changes.

If the featured categories can live together, option 1 is the cleaner one. If they must stay spread across your tree, option 2 is the way.
On our end, we'll look at what we can do to allow for this in the future as I think this would be great to allow more flexibility here.

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

  • Posts: 237
  • Thank you received: 13
1 week 3 days ago #372958

It's really strange that we don't have such a simple feature in Heikashop. The site has dozens of categories, and I want to show just a few of them in a module. I need the category information, like their images, canonical links, or their custom fields... so using joomla custom html module is not the way to do this ...

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

  • Posts: 86042
  • Thank you received: 14174
  • MODERATOR
1 week 2 days ago #372959

As I said yesterday, we'll look into this. In fact, I've already looked into it before reading your message today and I've made some improvements to allow for it. So you just have to wait for the next release if the alternatives I propose do not meet your needs.

Last edit: 1 week 2 days ago by nicolas.
The following user(s) said Thank You: khashiz

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

  • Posts: 237
  • Thank you received: 13
1 week 2 days ago #372962

Thank you very much
please consider the same thing for products as well

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

  • Posts: 86042
  • Thank you received: 14174
  • MODERATOR
1 week 2 days ago #372963

Hi,

For products you can easily do it. Create an unpublished category, configure the HikaShop content module to display the products of that category, and add the category to the products you wish to display in that module.

The following user(s) said Thank You: khashiz

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

  • Posts: 237
  • Thank you received: 13
4 days 9 hours ago #373030

I created a custom modules to select and display categpries .... i can get all of category infomation except its image .. how can i get the image of each category ?

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

  • Posts: 86042
  • Thank you received: 14174
  • MODERATOR
4 days 5 hours ago #373031

Hi,

The category image is not a column on the category table, which is why your module can read every field except the image. Images are stored in a separate table (hikashop_file), one row per image, linked to the category with file_type = 'category' and file_ref_id = the category id. A category can have several images.

So you have two options.

1) Let the category class attach the image for you. When you load the categories through HikaShop's category class, pass its "category_image" argument as true, and each row then carries file_path (plus file_name and file_description):

$categoryClass = hikashop_get('class.category');
// getChildren($parentId, $all, $filters, $order, $start, $limit, $category_image = true)
$categories = $categoryClass->getChildren($parentId, false, array(), '', 0, 100, true);

If you hand-pick the categories by id instead of by parent, just load their images yourself and match them on the category id:
$db = JFactory::getDbo();
$db->setQuery('SELECT file_ref_id, file_path, file_name, file_description FROM '.hikashop_table('file').
	' WHERE file_type = '.$db->quote('category').' AND file_ref_id IN ('.implode(',', $ids).') ORDER BY file_ordering ASC');
$images = $db->loadObjectList('file_ref_id'); // keyed by category id
// $images[$categoryId]->file_path is the image path of that category

2) To display it the way HikaShop does (same resized and cached thumbnail, same img tag), give that file_path to the image helper:
$image = hikashop_get('helper.image');
$options = array('default' => true, 'forcesize' => true, 'scale' => 'inside');
$thumb = $image->getThumbnail($cat->file_path, array('width' => $image->main_thumbnail_x, 'height' => $image->main_thumbnail_y), $options);
echo $image->renderImgFrom($thumb, array('class' => 'hikashop_category_image', 'alt' => $cat->file_name));

That last part is exactly what the default category listing uses (front/views/category/tmpl/listing_img_pane.php), so your module will match the rest of the shop.

The following user(s) said Thank You: khashiz

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

Time to create page: 0.068 seconds
Powered by Kunena Forum