Custom product template

  • Posts: 28
  • Thank you received: 0
10 years 4 months ago #200206

-- HikaShop version -- : latest

Hello,

I need to create a separate product template for the details of the product (ie. product/show) for only certain products/categories. As far as I can tell, you can only set this option in the configuration menu under display / "Default parameters for products" -> "Layout on product page".

How do you specify the product template (not the listing template)? When creating a new menu and/or module, under the "Parameters for products" there is no way that I can find to select a product view template.

If this isn't implemented, can I edit the DB to set the product template for a specific menu/module?

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 4 months ago #200217

Hi,

As you say, that's something you want to do only for certain products/categories and you want that for the product page, not the listings, which is why the "Layout on product page" setting you're looking for is not in the menus/modules but in the products or categories directly: take.ms/W5FKU

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

  • Posts: 28
  • Thank you received: 0
10 years 4 months ago #200421

Hey Nicolas,

Thanks for the quick reply.

Perhaps you may want to also add this layout function to the category/product modules. Let me give you an example why:

Let's say I have one product and 3 different modules ('full detail', 'quick sale' and 'members only'). The full detail view gives everything about the product, the quick sale only shows brief info and no picture, and the members only layout is designed specifically for members and has extra data in it (for example purposes, of course you could check for member status in php and add it to any layout).

If we default all products to 'detail view' via the product module base layout, does this mean we need to have 3 versions of the same product? Since we need a version that uses the default/inherited layout, a version that uses the quick layout and a version that uses the member layout.

However if we had 3 modules, one for quick view, one for full view and one for member view, we can assign all products assigned to these modules to have these views. So one product can be called by 3 distinct modules without having to adjust the individual products layout value for each unique display.

The way you have it now doesn't flow properly since it is at the end-point of the system. Since it is assigned only at the product screen, you cannot dynamically alter it based on which module it is part of. It will only ever have it's designated layout. This restricts design choices.

If you are forced to have 3 different products on the back-end, one for each product layout view, this just messes with inventory levels.

Also... it'd be great if you could add a layout view to the url so you can link products with a specific layout from elsewhere on the page / externally. Ie. &layout=unique_layout_alias

Last edit: 10 years 4 months ago by Cedwyn.

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

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 4 months ago #200430

Hi,

It is much more common in online shops to have different layouts for different categories of products, than different layouts for the same products but accessed from different places. So it's only normal that we did it at the product level.

But it would actually be quite easy to support that capability yourself.
Just add such code at the beginning of the file "show" of the view "product" for your frontend template via the menu Display>Views:

<?php
$layout = $this->productlayout; //normal selected layout
global $Itemid; //get the current menu item id
if($Itemid=='WWW'){
 $layout = 'XXX';  // use the layout called XXX for when the current menu item has the id WWW
}elseif($Itemid=='YYY'){
 $layout = 'ZZZ';  // use the layout called ZZZ for when the current menu item has the id YYY
}elseif(!empty($_GET['layout_name'])){
 $layout = $_GET['layout_name'];  // use the value of the variable layout_name of the URL of the page as layout if that parameter is specified. note that you can't use "layout" in the URLs are it is a reserved word used by Joomla for controller/task routing which is why I changed it to "layout_name" instead in this example.
}
$this->productlayout = $layout; //set the layout to use for the product page
?>

Last edit: 10 years 4 months ago by nicolas.
The following user(s) said Thank You: oxido

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

  • Posts: 28
  • Thank you received: 0
10 years 4 months ago #200515

Hello Nicolas,

Once again, thanks for the quick reply, great customer service =)

I'll look into adjusting the code and category display.

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

Time to create page: 0.062 seconds
Powered by Kunena Forum