Extend HS with own table fields on productpage

  • Posts: 68
  • Thank you received: 2
10 years 3 months ago #167222

-- HikaShop version -- : latest

Hi,

I'd like some directions on how to extend Hikashop.

Case:

I've created my own DB-table containing "color-records".
I'd like to display this colors on my product-page.
I'd like to customise HS in this way that I do not lose customisations after updating to newer release.
I do know how to customise display by HS-overriding-system, I've done this and this works fine.

I'd like to know how to "fetch" the table-data (colors-table), what kind of php-file do I have to create and in which directory and how to pass it to the product-display-view?

In short:

1. read DB-table
2. create colors-dataset
3. pass colours-dataset to the product-display-view

I know how to code this in PHP andI could do this with AJAX by jQuery but that is no what I want, I'd like to fix this the Joomla / Hikashop-way

Any info is appreciated.

Thanks in advance.

Mark

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 3 months ago #167282

Hi,

I am not sure that I understand why you want to use an external table for your "color-records" regarding the HikaShop custom field system.

There are too many ways to do that.
The two main solutions are :

- You can just put your php code in the "product | show_default" view, using the Joomla database system to make your query and display the information.
docs.joomla.org/Selecting_data_using_JDatabase
I don't see any requirements to create extra php files to just fetch the database in the product page.

- You can create your own custom field, like we did for the plugin "date picker".
www.hikashop.com/support/support/documen...r-documentation.html
The best is to read the content of the plugin itself ; it's a different finality but it is a good example for "how create a new kind of custom field".

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 68
  • Thank you received: 2
10 years 3 months ago #167339

Jerome thanks for quick response.

I thought so but I thought it's bad practice to put DB-actions within views? In this case probably its OK because it's a small imprint but it's not adhering coding-best-practices I guess. On the other hand: why "over coding" for such small functionality.

The case is this:

My color-record consists of:
-color-active
-colorname
-color-image
-colortype
-colorversion

In the frontend (productpage) I build a color-matrix from which the customer can select one color.
Sometimes color are inactive so I only show active colours of that moment.

I've created my own component (with component-creator) for the color-crud function.

Thats why I'd like to integrate my own component (solution) in the frontend of Hikashop.

Anyway thanks for responding.

Mark

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 3 months ago #167359

Hi,

If you want to organize the code in order to have something "code-best-practice", I will suggest you to use a plugin and some triggers like "onHikashopBeforeDisplayView" in order to call a special custom class and modify the $view content.
HikaMarket uses this trigger to modify some view elements which are displayed in the view afterwards (extraData->topEnd & others).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.059 seconds
Powered by Kunena Forum