Do you like AbanteCart? Please rate AbanteCart or share your experience with other eCommerce entrepreneurs. Go to Softaculous rating page to add your rating or write a review

create submenu when admin turn on an extension

Started by yonghan, June 30, 2015, 05:30:13 AM

Previous topic - Next topic

yonghan

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

abolabo

"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

yonghan

Sorry I didn't ask clearly. Submenu on admin side. Thanks.

abolabo

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
"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

yonghan

 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?

eCommerce Core

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.
"If you're in the luckiest one per cent of humanity, you owe it to the rest of humanity to think about the other 99 per cent."
― Warren Buffett

abolabo

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

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;
}
}
"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

yonghan

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.

Forum Rules Code of conduct
AbanteCart.com 2010 -