Jump to content

I can't get HelperList working on GetContent in module


hakeryk2

Recommended Posts

Hello community,
 
I am developing a module and I need use helperList in public function getContent (responsible for module configuration page) but I have a problem. I menaged to generate the table with content and sorting headers that I want but I can't use filtering options which is pretty essential in my case. When I try to sort table I am redirected to module list page with 
http://localhost/prestashop/admincyferski/index.php?controller=AdminModules&token=some-kind-of-token&submitFilterconfiguration=1#configuration

Code of my getContent is this:
 
public function getContent()
    {
        $employees = $this->getAllEmployeesId();
        $employees_names = array();
        foreach ($employees as $id){
            $e = new EmployeeCore($id);
            $employees_names[$id] = $e->firstname.' '.$e->lastname;
        }

        $ingerence_status = array (
            0 => $this->l('Bezobsługowe'),
            1 => $this->l('Do decyzji'),
            2 => $this->l('Obsługowe')
        );

        $sql = 'SELECT * FROM '._DB_PREFIX_.$this->name;
        $result = Db::getInstance()->executeS($sql);

        $this->fields_list = array(
             'id' => array(
                 'title' => 'ID ',
                 'width' => 'auto',
                 'type' => 'text',
                 'class' => 'fixed-width-xs'
             ),
            'id_order' => array(
                'title' => $this->l('ID Zamówienia'),
                'width' => 'auto',
                'type' => 'text',
                'class' => 'fixed-width-xs'
            ),
            'id_employee' => array(
                'title' => $this->l('Pracownik'),
                'width' => 'auto',
                'type' => 'select',
                'filter_key' => 'id_employee',
                'list' => $employees_names
            ),
            'submitted_by' => array(
                'title' => $this->l('Przydzielił'),
                'width' => 'auto',
                'type' => 'select',
                'filter_key' => 'submitted_by',
                'list' => $employees_names
            ),
            'ingerence' => array(
                'title' => 'Status',
                'width' => 'auto',
                'type' => 'select',
                'list' => $ingerence_status,
                'filter_key' => 'ingerence',
            ),
            'date' => array(
                'title' => $this->l('Data'),
                'width' => 'auto',
                'type' => 'date',
                'filter_key' => 'date',
            ),
        );

        $helper = new HelperList();

        $helper->allow_export = true;
        $helper->context = Context::getContext();
        $helper->title = $this->displayName;
        $helper->className = $this->name;
        $helper->show_toolbar = true;
        $helper->simple_header = false;
     
        $helper->identifier = 'id';
        $helper->actions = array('edit', 'delete', 'view');
        $helper->shopLinkType = ''; 
        $helper->token = Tools::getAdminTokenLite('AdminModules');
        $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module='.$this->tab.'&modulename='.$this->name;

        return $helper->generateList($result, $this->fields_list);
    }

I tried with $this->context->link->getAdminLink('AdminModules', false) on true but it didn't work either.

Prestashop version is 1.6.1.4

Edited by hakeryk2 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...