Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: create submenu when admin turn on an extension  (Read 7436 times)

yonghan

  • Guest
create submenu when admin turn on an extension
« 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

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: create submenu when admin turn on an extension
« Reply #1 on: June 30, 2015, 05:40:50 AM »
submenu where? on sf or admin side?
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

yonghan

  • Guest
Re: create submenu when admin turn on an extension
« Reply #2 on: June 30, 2015, 06:06:32 AM »
Sorry I didn't ask clearly. Submenu on admin side. Thanks.

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: create submenu when admin turn on an extension
« Reply #3 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
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

yonghan

  • Guest
Re: create submenu when admin turn on an extension
« Reply #4 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?

Offline eCommerce Core

  • Administrator
  • Hero Member
  • *****
  • Posts: 1602
  • Karma: +93/-1
    • View Profile
Re: create submenu when admin turn on an extension
« Reply #5 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.
“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

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
  • Karma: +318/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: create submenu when admin turn on an extension
« Reply #6 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;
}
}
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

yonghan

  • Guest
Re: create submenu when admin turn on an extension
« Reply #7 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.

 

Powered by SMFPacks Social Login Mod