From db18e52fb754fcae4160778599dcdb16f4aafc10 Mon Sep 17 00:00:00 2001 From: Samuel Marchal Date: Mon, 26 May 2014 15:25:07 +0200 Subject: [PATCH] Allow to remove every item Removing every Top Menu item will raise a `Unable to update settings.` error. If `$items` is empty, we should consider it as a user request to clear the Top Menu. --- blocktopmenu.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blocktopmenu.php b/blocktopmenu.php index 1947184..edc2be7 100644 --- a/blocktopmenu.php +++ b/blocktopmenu.php @@ -146,7 +146,11 @@ class Blocktopmenu extends Module if (Tools::isSubmit('submitBlocktopmenu')) { $items = Tools::getValue('items'); - if (is_array($items) && count($items) && Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string)implode(',', $items))) + if (is_array($items) && count($items)) + $updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string)implode(',', $items)); + else + $updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', ''); + if ($updated) $this->_html .= $this->displayConfirmation($this->l('The settings have been updated.')); else $this->_html .= $this->displayError($this->l('Unable to update settings.'));