Question

I am working on adapting my custom prestashop modules to prestashop 1.6. The toolbar buttons at the configuration page are not showing on 1.6 (they do appear on 1.5) and no error message is given.

Toolbar in 1.5:

Toolbar in 1.5

No Toolbar in 1.6

No Toolbar in 1.6

Do anyone know how to show them in prestashop 1.6? This is the fragment of my code where I declare the toolbar:

  $helper = new HelperForm();

  // Module, token and currentIndex
  $helper->module = $this;
  $helper->name_controller = $this->name;
  $helper->token = Tools::getAdminTokenLite('AdminModules');
  $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;

  // Language
  $helper->default_form_language = $default_lang;
  $helper->allow_employee_form_lang = $default_lang;

  // Title and toolbar
  $helper->title = $this->displayName;
  $helper->show_toolbar = true;
  $helper->toolbar_scroll = true;      // yes - > Toolbar is always visible on the top of the screen.
  $helper->submit_action = 'delete'.$this->name;
  $this->uri = ToolsCore::getCurrentUrlProtocolPrefix() .$this->context->shop->domain_ssl.$this->context->shop->physical_uri;
  $helper->toolbar_btn = array(
      'import' => array(
          'desc' => $this->l('Descargar CSV'),
          'href' =>$this->uri. 'modules/' . $this->getName() . '/excel.csv',
      ),
      'delete' => array(
          'desc' => $this->l('Borrar CSV'),
          'href' => AdminController::$currentIndex.'&configure='.$this->name.'&delete'.$this->name.
          '&token='.Tools::getAdminTokenLite('AdminModules'),
      ),
      'back' => array(
          'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
          'desc' => $this->l('Back to list')
      )
 );

Thanks in advance.

Was it helpful?

Solution

After doing some research I tried using HelperList instead of HelperForm and the toolbar buttons do appear but at the list header, instead of the green area.

On the other hand, HelperForm provides a "buttons" array (I'm not sure if that is a Prestashop 1.6 change or it was there on the 1.5.x versions) which appear left to the submit button in a sort of toolbar below the form. buttons

$this->fields_form[0]['form'] = array(
    'tinymce' => true,
    'legend' => array(
        'title' => $this->l('New test block'),
    ),
    'input' => array(
        array(
            'type' => 'textarea',
            'label' => $this->l('Text'),
            'lang' => true,
            'name' => 'text',
            'cols' => 40,
            'rows' => 10,
            'class' => 'rte',
            'autoload_rte' => true,

        )
    ),
    'submit' => array(
        'title' => $this->l('Save'),
    ),
    'buttons' => array(
        array(
            'href' => AdminController::$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'),
            'title' => $this->l('Back to list'),
            'icon' => 'process-icon-back'
        )
    )
);

I suppose the toolbar behaviour and purpose has changed along with the new backend theme.

OTHER TIPS

I've been helping fixing a module we did develope for prestashop, and this was one of the bug we found out. If you want to show any information in the green bar, you will have to use the property $page_header_toolbar_btn from extending AdminCrontrollerCore class which is located at "/classes/controller" until the prestashop team fix the bug I'll report. If you want to make your plugin compatible with older version you will have to use _PS_VERSION global variable.

Edit: https://github.com/PrestaShop/PrestaShop/pull/2065 pull request to solve the bug.

Here is my example code:

    class AdminOrdersController extends AdminOrdersControllerCore
    {

    .....  

    public function initToolbar()
    {
    if ($this->display == 'view' && $this->_order->module == 'mymodule') {
            if ($this->_mymodule->isOrderComplete($this->_order)) {
                $mymodule_return = array(
                    'short' => $this->l('mymodule account'),
                    'href' => self::$currentIndex . '&id_order=' . $this->_order->id . '&vieworder&return_mymodule=1&token=' . $this->token,
                    'desc' => $this->l('return to mymodule'),
                    'class' => 'process-icon-standardreturn mymodule-return',
                );
                $mymodule_partial_return = array(
                    'short' => 'return customer mymodule account',
                    'href' => '#',
                    'desc' => $this->l('return to mymodule'),
                    'class' => 'process-icon-partialreturn',
                );

                //Depend of the prestashop version, we use $toolbar_btn[]
                // or we use $page_header_toolbar_btn[]
                if (_PS_VERSION_ > '1.5') {
                    $mymodule_return['class'] = "process-icon-delete mymodule-return";
                    $this->page_header_toolbar_btn['return_mymodule'] = $mymodule_return;

                } else {
                    $this->toolbar_btn['return_mymodule'] = $mymodule_return;
                    $this->toolbar_btn['return_mymodule_partial'] = $mymodule_partial_return;
                }
            }
        }      
    }  
   }        

I also search for way to display buttons in HelperList, but I want them appear in panel-footer.

The only button, that works this way, is back button.

    $helperList->toolbar_btn = array(
        'back' => array(
            'href' => $this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&add_new_feed=1',
            'desc' => $this->l('New Feed')
    ));

prestashop button

Obviously, the drawback is in icon, which don't corespond with the purpose.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top