AbanteCart Community

AbanteCart Development => Development Help Needed => Topic started by: yonghan on June 30, 2015, 05:30:13 AM

Title: create submenu when admin turn on an extension
Post by: yonghan on June 30, 2015, 05:30:13 AM
Hi admins, I wonder if it's possible to hook extension edit page in order to create submenu when admin turn on an extension? Thanks
Title: Re: create submenu when admin turn on an extension
Post by: abolabo on June 30, 2015, 05:40:50 AM
submenu where? on sf or admin side?
Title: Re: create submenu when admin turn on an extension
Post by: yonghan on June 30, 2015, 06:06:32 AM
Sorry I didn't ask clearly. Submenu on admin side. Thanks.
Title: Re: create submenu when admin turn on an extension
Post by: abolabo on June 30, 2015, 06:18:06 AM
you can look into two extensions inside distributive, i mean forms_manager and banner_manager. Both have install.php and uninstall.php that creates and removes menu item
Title: Re: create submenu when admin turn on an extension
Post by: yonghan on June 30, 2015, 06:30:41 AM
 I have looked at banner_manager and currently I'm using that approach for my extension, but I would like to create the submenu only when the extension is turned on and not installed. Is it possible to do that?
Title: Re: create submenu when admin turn on an extension
Post by: eCommerce Core on June 30, 2015, 10:27:40 AM
Currently, any installed/enabled extension is treated as enabled extension in admin. This is done on purpose to allow access to controllers even if extension is set to status OFF. In over words, this allows user to still edit custom extension settings or access pages with extension related data.

For instance, In case of payment extensions, you still what to see payment history even if extension is disabled and no longer available in a storefront.

Regarding you question. We are looking into solution that will be logical in 1.2.3.
I will update.
Title: Re: create submenu when admin turn on an extension
Post by: abolabo on June 30, 2015, 06:21:06 PM
well.. we added additional hook call for affecting on data of admin menu into v1.2.3 ( see details https://github.com/abantecart/abantecart-src/commit/804c6b35007e91b47487f1956c815405cd8548d9)

then in your extension hook-file you can add this method

Code: [Select]
public function onControllerCommonMenu_ProcessData(){
$that = $this->baseObject;

if(!$that->config->get('your_extension_txt_id_status')){
$items = $that->data['menu_items'];
foreach ($items as $k=>$item) {
if($item['item_id']=='your_extension_txt_id_menu_item_id'){
unset($items[$k]);
break;
}
}
$that->data['menu_items'] = $items;
}
}
Title: Re: create submenu when admin turn on an extension
Post by: yonghan on July 01, 2015, 11:01:39 PM
Thanks a lot eCommerce Core and abolabo for the explanation and the added feature in v1.2.3. I will use the current solution then while waiting for the v1.2.3.