Creating Prestashop back-office module with settings page -


i'm creating back-office module prestashop , have figured out except best way display admin page. i'm using renderview() method display content of view.tpl.

i display table values , option add new row. should create in view.tpl or there better way? i've seen renderform() method haven't figured out how works yet.

the biggest question have is, how submit content controller specific method?

moduleadmincontroller meant managing kind of records, objectmodels. defauly page controller list, can edit each record individually or view it's full data (view).

if want have settings page, best way create getcontent() function module. besides helperoptions better helperform module configuration page because automatically laods values. define form in function , above add 1 if (tools::issubmit('submit'.$this->name)) - submit button name, save values configuration table. configuration::set(...).

of course possible create sort of settings page in admincontroller, not meant that. if want to: got hookcore.php , find exec method. add error_log($hook_name) , hooks executed when open/save/close page/form. maybe you'll find hook way. bettter way inspect parent class admincontrollercore or controllercore. have specific function ready overriden, should save stuff. part of execution process, empty.

edit: should take @ other admincontroller classes, wuite simple; need define properties in order work:

public function __construct() {     // define associated model     $this->table = 'eqa_category';     $this->classname = 'eqacategory';      // add record actions     $this->addrowaction('edit');     $this->addrowaction('delete');      // define list columns     $this->fields_list = array(         'id_eqa_category' => array(             'title'    => $this->l('id'),             'align'    => 'center',         ),           'title' => array(             'title'    => $this->l('title'),         ),     );      // define fields edit form     $this->fields_form = array(         'input' => array(             array(                 'name'     => 'title',                 'type'     => 'text',                 'label'    => $this->l('title'),                 'desc'     => $this->l('category title.'),                 'required' => true,                 'lang'     => true             ),         'submit' => array(             'title' => $this->l('save'),         )     );      // call parent constructor     parent::__construct(); } 

other people move list , form definitions actual functions render them:

public function renderform() {     $this->fields_form = array(...);      return parent::renderform(); } 

you don't need else, controller matches fields models, loads them, saves them etc.

again, best way learn these controller @ other admincontrollers.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -