Jump to content

table and new module


sadlyblue
 Share

Recommended Posts

Hi,

 

I've been developing some modules for our usage, and was never concerned about this. But i think it's time to ask.
What is the best way to show a table in a module?

 

For example, i can use generateForm to show a for to insert values in the the sql table. Then i need another table to show the results. I've been coding all using tables and cycles, but is there a similar way to the generateForm for tables?

 

Thanks

Share this post


Link to post
Share on other sites

You can try helper generateList() like below 

    public function displayList() {
        
        $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'tablename';

        if ($result = Db::getInstance()->ExecuteS($sql)) {
            $this->fields_list = array(
                'id_tablename' => array(
                    'title' => 'ID',
                    'width' => 'auto',
                    'type' => 'text'
                ),
                'name' => array(
                    'title' => $this->l('Name'),
                    'width' => 'auto',
                    'type' => 'text'
                ),
               ...
            );

            $helper = new HelperList();
            $helper->shopLinkType = '';
            $helper->simple_header = true;
            $helper->actions = array('edit', 'delete');
            $helper->identifier = 'id_tablename';
            //$helper->actions = array('edit', 'delete');
            $helper->show_toolbar = false;
            $helper->title = $this->className;
            $helper->table = $this->name;
            $helper->token = Tools::getValue('token');
            $helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
            return $helper->generateList($result, $this->fields_list);
        }

      return false;
    }
  • Like 1

Share this post


Link to post
Share on other sites

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More