- Posts: 2
- Thank you received: 2
Add some extra field to category admin page by plugin
4 years 2 months ago #343470
by mortezafs
Add some extra field to category admin page by plugin was created by mortezafs
-- HikaShop version -- : 4.5.1
-- Joomla version -- : 4.1.1
-- PHP version -- : 7.4
-- Browser(s) name and version -- : Mozila FireFox
Hi.
I wan't to add some extra field in admin create/edit category form. I wrote a plugin to add some, but there is not useful event for adding fields to form. Anybody can give some guidance on how to add some new fields to the category fields using the plugin?
By regard.
-- Joomla version -- : 4.1.1
-- PHP version -- : 7.4
-- Browser(s) name and version -- : Mozila FireFox
Hi.
I wan't to add some extra field in admin create/edit category form. I wrote a plugin to add some, but there is not useful event for adding fields to form. Anybody can give some guidance on how to add some new fields to the category fields using the plugin?
By regard.
Please Log in or Create an account to join the conversation.
4 years 2 months ago - 4 years 2 months ago #343473
by Philip
Replied by Philip on topic Add some extra field to category admin page by plugin
Hello,
When you develop a plugin for HikaShop, you can have some elements in our Documentation , here you will find some elements in our Developer Area.
I guess that you will find a solution by using the most useful trigger detailed, here .
Hope this will help you to achieve your plugin.
Regards
When you develop a plugin for HikaShop, you can have some elements in our Documentation , here you will find some elements in our Developer Area.
I guess that you will find a solution by using the most useful trigger detailed, here .
Hope this will help you to achieve your plugin.
Regards
Last edit: 4 years 2 months ago by Philip.
The following user(s) said Thank You: levelup
Please Log in or Create an account to join the conversation.
4 years 2 months ago - 4 years 2 months ago #343533
by mortezafs
Thank you for your help but i read this documentation before i create this topic.
In this duration to you response i found a solution. I'll share it with you. maybe someone need it in the feature.
I simulated the process of creating hikashop's custom fields in the plugin.
1- First of all you need create columns with name of your field in hikashop category table (#__hikashop_category)
2- Then you need append the fields you want to create with bellow structure to the $viewObj->fields array in onHikashopBeforeDisplayView event.
Note: The structure is the same for all type of field but there is some change with field type like singledropdown or textbox , ...
You can find more about the fields type special serialized data by creating filed in hikashop custom filed and looking to the #__hikashop_field table.
it so important to know the array key in $viewObj->fields is your field name and value should be an object.
The structure:
Replied by mortezafs on topic Add some extra field to category admin page by plugin
Philip wrote: Hello,
When you develop a plugin for HikaShop, you can have some elements in our Documentation , here you will find some elements in our Developer Area.
I guess that you will find a solution by using the most useful trigger detailed, here .
Hope this will help you to achieve your plugin.
Regards
Thank you for your help but i read this documentation before i create this topic.
In this duration to you response i found a solution. I'll share it with you. maybe someone need it in the feature.
I simulated the process of creating hikashop's custom fields in the plugin.
1- First of all you need create columns with name of your field in hikashop category table (#__hikashop_category)
2- Then you need append the fields you want to create with bellow structure to the $viewObj->fields array in onHikashopBeforeDisplayView event.
Note: The structure is the same for all type of field but there is some change with field type like singledropdown or textbox , ...
You can find more about the fields type special serialized data by creating filed in hikashop custom filed and looking to the #__hikashop_field table.
it so important to know the array key in $viewObj->fields is your field name and value should be an object.
The structure:
Code:
$viewObj->fields['namekey_of_field'] = (object) [
'field_id' => '',
'field_table' => 'category',
'field_realname' => '',
'field_namekey' => '',
'field_type' => 'text',
'field_value' => '',
'field_published' => 1,
'field_ordering' => 1,
'field_options' => [
'errormessage' => '',
'regex' => '',
'attribute' => '',
'placeholder' => '',
'inline' => '0',
'target_blank' => '1',
'allow_add' => '0',
'cols' => '',
'filtering' => '1',
'maxlength' => '0',
'rows' => '',
'zone_type' => 'country',
'pleaseselect' => '0',
'size' => '',
'format' => '%Y-%m-%d',
'allow' => '',
'allowed_extensions' => '',
'upload_dir' => '',
'max_filesize' => '0',
'max_width' => '0',
'max_height' => '0',
'multiple' => '0',
'readonly' => '0',
'mysql_query' => '',
'datepicker_options' => [
'today' => '0',
'inline' => '0',
'monday_first' => '0',
'change_month' => '0',
'change_year' => '0',
'year_range_start' => '',
'year_range_end' => '',
'show_btn_panel' => '0',
'show_months' => '1',
'other_month' => '0',
'exclude_days_format' => 'mdY',
'waiting' => '',
'hour_extra_day' => '',
'check_dates' => 'all'
]
],
'field_core' => 0,
'field_required' => 0,
'field_default' => '',
'field_access' => 'all',
'field_categories' => 'all',
'field_with_sub_categories' => 0,
'field_products' => '',
'field_address_type' => '',
'field_frontcomp' => 0,
'field_backend' => 1,
'field_backend_listing' => 0,
'field_display' => null,
'field_shipping_id' => '',
'field_payment_id' => '',
'guest_mode' => true,
'field_url' => str_replace('/', '\/', JURI::base()) . '/administrator\/index.php?option=com_hikashop&ctrl=field&task=state&tmpl=component&'
];
Last edit: 4 years 2 months ago by mortezafs. Reason: Remove some commented code
Please Log in or Create an account to join the conversation.
Time to create page: 0.200 seconds