dineshphp Posted January 8, 2015 Share Posted January 8, 2015 (edited) I am using prestashop version 1.6 in localhost. I need to add our own video section in admin / back office to manage and display those videos in a separate page in front end. For example, about us and term and conditions pages like that. I have developed my own module upto configuration section of the module. Now i need to add my own form fields like title, embedcode and submit button. I dont know how to add our own form fields with "helper class" of prestashop. Also i have read the documentation but could not able to get. Can you guide me please ? Thanks in advance and sorry for my english. Edited January 8, 2015 by dineshphp (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted January 9, 2015 Share Posted January 9, 2015 I'd forget the helper class. It's very limited in terms of functionality, and overly complex. I generally work my own way by copying outputs somewhere and adding them manually, like: <h4>'.$this->l('Add a category').'</h4> <div class="form-group"> <label class="control-label col-lg-2">'.$this->l('Parent ID').'</label> <div class="col-lg-3"> <input type="text" name="parentFilter" value="'.(Tools::isSubmit('parentFilter') ? Tools::getValue('parentFilter') : '').'"/> </div> <div class="col-lg-2"> <input class="btn btn-default" type="submit" name="submitParentFilter" value="'.$this->l('Filter!').'" > </div> </div> 1 Link to comment Share on other sites More sharing options...
dineshphp Posted January 9, 2015 Author Share Posted January 9, 2015 Thats nice. Can you guide me to get form fields in page ? This will use to avoid future issues. Link to comment Share on other sites More sharing options...
NemoPS Posted January 9, 2015 Share Posted January 9, 2015 For fields like? That is a form field actually Link to comment Share on other sites More sharing options...
dineshphp Posted January 9, 2015 Author Share Posted January 9, 2015 ok fine nemo.., Below is my code for your reference and kindly let me know where can i add these lines please ? videomodule.php: <?php if (!defined('_PS_VERSION_')) exit; class VideoModule extends Module { public function __construct() { $this->name = 'videomodule'; $this->tab = 'video'; $this->version = 1.0; $this->author = 'Dinesh Kumar'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Video Module'); $this->description = $this->l('It is really an awesome experience'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); Configuration::updateValue('video', serialize(array(true, true, false))); if (!Configuration::get('videomodule')) $this->warning = $this->l('No name provided'); // echo Configuration::get('videoid'); } public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('videomodule')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('videomodule', $my_module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->displayForm(); } public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Settings'), ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Configuration value'), 'name' => 'videomodule', 'size' => 20, 'required' => true ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); $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; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['videomodule'] = Configuration::get('videomodule'); return $helper->generateForm($fields_form); } public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('header') || !Configuration::updateValue('videomodule', 'my friend') ) return false; return true; } public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('videomodule') ) return false; return true; } public function hookLeftColumn( $params ) { global $smarty; return $this->display(__FILE__,'videomodule.tpl'); } public function hookRightColumn($params) { return $this->hookLeftColumn($params); } } Link to comment Share on other sites More sharing options...
NemoPS Posted January 10, 2015 Share Posted January 10, 2015 DisplayForm. You must get rid of all that and use manual code instead. Make sure you open a div classed "panel" inside a form with class "defaultForm form-horizontal" <form action="'.$_SERVER['REQUEST_URI'].'" method="post" class="defaultForm form-horizontal"> <div class="panel"> ... </div> </form> Link to comment Share on other sites More sharing options...
dineshphp Posted January 12, 2015 Author Share Posted January 12, 2015 @nemo1 : thanks for an idea. I have tried as you said but it shows some prestashops exceptions. any suggestions ?? Link to comment Share on other sites More sharing options...
NemoPS Posted January 12, 2015 Share Posted January 12, 2015 Which method are you calling? Does your module have a postProcess() method? Link to comment Share on other sites More sharing options...
dineshphp Posted January 13, 2015 Author Share Posted January 13, 2015 (edited) Oh Thank you So much nemo. Now i have resolved my problem by writing my own custom function. Thanks again to save me.., Edited January 13, 2015 by dineshphp (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts