Hi,
I am new in prestashop. I am trying to develop a simple module.
Two text box on front end 1.Name, 2. Phone no.
Two value will inserted in database.
I have't get value from front end tpl file. And my module was working fine through back end panel.
My mymodule.php file like this
<?php
/*
*
*/
if(!defined('_PS_VERSION_'))
exit;
class MyModule extends Module {
/** @var max image size */
protected $maxImageSize = 307200;
public function __construct() {
$this->name = 'mymodule';
$this->tab = 'front_office_features';
$this->version = '0.0.1';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Mymodule');
$this->description = $this->l('Mymodule.');
$this->confirmUninstall = $this->l('Are you sure to uninstall Mymodule?');
}
public function install() {
if (!parent::install() || !$this->installDB() || !$this->registerHook('home') || !$this->registerHook('header'))
return false;
return true;
}
public function installDB(){
if (!Db::getInstance()->Execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'storewhatapps` (
`store_id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`phone_num` int(15) NOT NULL,
PRIMARY KEY (`store_id`))
ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'))
return false;
return true;
}
public function uninstall() {
if (!parent::uninstall() || !$this->uninstallDB())
return false;
return true;
}
public function getContent() {
$name=Tools::getValue('name');
$phone_number=Tools::getValue('phone_number');
if (Tools::isSubmit('submit_details')) {
if(Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'storewhatapps` (`store_id`, `name`, `phone_num`)
VALUES ("","'.$name.'","'.$phone_number.'")')) {
$this->_html .=$this->displayConfirmation($this->l('Settings updated successfully'));
} else {
$this->_html .= $this->displayError($this->l('You Have Some Errors'));
}
}
//$this->_displayForm();
$this->display(__FILE__, 'mymodule.tpl');
//return $this->_html;
return $this->display(__FILE__, 'mymodule.tpl');
}
public function hookHome($params) {
return $this->display(__FILE__, 'mymodule.tpl');
}
public function hookHeader() {
$this->context->controller->addCSS(($this->_path).'css/store_styles.css', 'all');
}
}
And my mymodule.tpl file look like this
<fieldset>
<form id="formID" method="post" action="#">
<p>
<label for="name">Name:</label>
<input id="name" name="name" type="text"/>
</p>
<p>
<label for="phone_number">Phone Number:</label>
<input id="phone_number" name="phone_number" type="text" />
</p>
<p>
<label> </label>
<input type="submit" name="submit_details" class="button" />
</p>
</form>
</fieldset>
Please guide me