Custom field view override

  • Posts: 354
  • Thank you received: 19
  • Hikashop Business
3 years 1 month ago #340792

-- HikaShop version -- : 4.5.0

Is there any posibility to override view of custom field.
I can do it with core Joomla custom fields, but not with Hikashop.

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

  • Posts: 4820
  • Thank you received: 654
  • MODERATOR
3 years 1 month ago #340794

Hello,

It is possible, have a look on this documentation to learn how to perform override view in HikaShop.

And now a little tips, as a custom field can be display in looots of different views, use the "Display view file" option, from Main HikaShop Configuration, Advanced tab and first settings part.
If you activated it (frontend) you will have view file references and know which view file you have to edit.

Hope this will help you to achieved your needs
Regards

Last edit: 3 years 1 month ago by Philip.

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

  • Posts: 354
  • Thank you received: 19
  • Hikashop Business
3 years 1 month ago #340856

This I understand, but there is only show_block_custom_item. I need to override only custom field type Ajax file or image.
So output for specific type.
In Joomla this is easy.

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

  • Posts: 83777
  • Thank you received: 13561
  • MODERATOR
3 years 1 month ago #340858

Hi,

Custom fields don't have view files.
The HTML of a custom field is generated in different places. For example, a "text" type custom field will have the HTML of the input generated directly in the file administrator/components/com_hikashop/classes/field.php
Now that doesn't mean that this HTML display cannot be overridden. It can in fact, but not with a view override. It can be done by developing a plugin implementing the Fields API to add your own custom type of custom fields. In your own type of custom field, you can extend from an existing custom field type class and that way, you can redefine things up.
However, this isn't easy as it requires proper PHP knowledge. We do have documentation on this here:
www.hikashop.com/support/documentation/6...entation.html#fields

Now, besides this, there are also other things that can be done:

- AJAX custom fields use texts for their display. So if you want to change these texts, you can use translation overrides to modify them: www.hikashop.com/download/languages.html#modify
That's much much easier than developing a plugin or making a view override

- While the HTML of a custom field is not generated in a view file, it's a view file which calls the custom field system to generate that HTML. So there are many things you can do in the view file calling the custom field system to either dynamically modify the parameters of the custom field before the custom field system is called, or modifying the HTML returned after the custom field system is called. In HikaShop 4.5.1 the code generating the HTML of the custom field of the table "item" on the product details page is:

$html = $this->fieldsClass->display(
		$oneExtraField,
		$itemData,
		'data[item]['.$oneExtraField->field_namekey.']',
		false,
		' '.$onWhat.'="window.hikashop.toggleField(this.value,\''.$fieldName.'\',\'item\',0);"',
		false,
		$this->itemFields
	);
in the view file show_block_custom_item.
So for example, you could change the type of the custom fields to text with such code before that line:
if($oneExtraField->field_namekey == 'xxx') {
 $oneExtraField->field_type='text';
}
where xxx is the column name of the custom field.
Similarly, after that line, you could use such code to change the HTML of the custom field:
if($oneExtraField->field_namekey == 'xxx') {
 $html = str_replace('<input ','<input autocomplete="off" ', $html);
}
This code would add an autocomplete attribute to a text custom field for example.

- Finally, since you're using custom fields of the type AJAX, they use the uploader system we have in HikaShop. That uploader system actually uses view files to generate preview of each uploaded element. So if you search for "upload" in the Display>Views menu, you'll see that you have both file_entry and image_entry view files which are actually used to generate the HTML of each element already uploaded in the uploader. So these view files could be overridden too.

So in short, since you didn't say what modification you wanted to make I can't tell you what would be the appropriate way to go. Overrides can be done but the complexity will depend on what you want to change.

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

Time to create page: 0.062 seconds
Powered by Kunena Forum