sadlyblue Posted May 19, 2015 Share Posted May 19, 2015 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 Link to comment Share on other sites More sharing options...
presta.show Posted May 19, 2015 Share Posted May 19, 2015 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; } 1 Link to comment Share on other sites More sharing options...
sadlyblue Posted May 20, 2015 Author Share Posted May 20, 2015 Thanks for the help.It worked great, and is exactly what i was looking for. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now