Proper template overrides in Hikashop please

  • Posts: 17
  • Thank you received: 1
9 years 1 month ago #195424

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.0

I am working with Bootstrap 3 and I want to change the look and feel of the display of characteristics table.
Therefor I want to add class = table table-condensed to the table tag of the characteristics display.

Just found out that I have to apply a Hikashop core hack to do so.
administrator/components/com_hikashop/types/characteristics.php
line 172 $main_html = '<table class="hikashop_product_characteristics_table">';

Why is this HTML output to display content on the frontend in Administrator?
Why is this piece of code to create HTML output placed in types and not in VIEWS?
How am I able to create a proper override in Hikashop when you put a lot of HTML output in files I cannot create template overrides with? (this is just an example of the many I stumbled upon)

Are you going to change this?
"that would be great"

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

  • Posts: 81515
  • Thank you received: 13068
  • MODERATOR
9 years 1 month ago #195441

Hi,

Most modifications that you did in code files of HikaShop are probably possible with view overrides, pluginsor other methods.
For example, for that table, there are two ways you can add such extra class without modifying the types/characteristics.php file.

One solution is to actually follow our documentation on customizing the display of the characteristics:
www.hikashop.com/support/support/documen...tation.html#override

You need to create the file templates/YOUR_TEMPLATE/html/hikashop_characteristics.php. We invite you to look at the file administrator/components/com_hikashop/type/characteristic.php for the default code of the function you will define in it. In that file, you will be able to define the function:
hikashop_characteristics_html(&$element,&$params,&$obj) => The $element variable will contain the whole product information from which you can extract the characteristics information and the params variable can help you get some parameters from the HikaShop configuration. The $obj variable will be the instance of the characteristic display class. That way, when you get the code from the characteristic.php file, you can just replace $this by $obj and it should work. You need to return the HTML of the characteristics selection at the end of your function.


Another, even simpler solution, is to edit the file "show_block_characteristic" via the menu Display>Views and change the line:
echo $this->characteristic->displayFE($this->element, $this->params) . '</div>';
to, for example:
echo str_replace('hikashop_product_characteristics_table','hikashop_product_characteristics_table table table-condensed',$this->characteristic->displayFE($this->element, $this->params)) . '</div>';

There is not much HTML used for the frontend in type/class/helper files of the backend. And for the few that there is, either we already started moving it in views, or have template overrides, or ways to modify them with view overrides.
But yes, our goal is to move more of the HTML bits in such core files into views in the future.

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

Time to create page: 0.055 seconds
Powered by Kunena Forum