jbike Posted August 28, 2013 Share Posted August 28, 2013 Hi I try to create my first module like in tutorial : http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module but I have problem. I created module You can see it in p1, but after click I had respond that the website is not available Are somebody have all files from tutorial - version 1.5 ? Thx Link to comment Share on other sites More sharing options...
vekia Posted August 28, 2013 Share Posted August 28, 2013 the question is what you've got in your "{$my_module_link}" variable from image that you attached i see that module works well, but the problem is with variable mentioned above. make sure that url in this variable is valid Link to comment Share on other sites More sharing options...
jbike Posted August 28, 2013 Author Share Posted August 28, 2013 <?php if (!defined('_PS_VERSION_')) exit; class MyModule extends Module { public function __construct() { $this->name = 'mymodule'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->author = 'Firstname Lastname'; $this->need_instance = 0; $version_test = $version_mask[0] > 0 && $version_mask[1] > 3; $this->dependencies = array('blockcart'); parent::__construct(); $this->displayName = $this->l('My module'); $this->description = $this->l('Description of my module.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('MYMODULE_NAME')) $this->warning = $this->l('No name provided'); } public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); return parent::install() && $this->registerHook('leftColumn') && $this->registerHook('header') && Configuration::updateValue('MYMODULE_NAME', 'my friend'); } public function uninstall() { if (!parent::uninstall()) Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'mymodule`'); parent::uninstall(); } public function hookDisplayLeftColumn($params) { $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display'), 'my_module_message' => $this->l('This is a simple text message') // Do not forget to enclose your strings in the l() translation method ) ); return $this->display(__FILE__, 'mymodule.tpl'); } public function hookDisplayRightColumn($params) { return $this->hookDisplayLeftColumn($params); } public function hookDisplayHeader() { $this->context->controller->addCSS($this->_path.'css/mymodule.css', 'all'); } public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('MYMODULE_NAME')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError( $this->l('Invalid Configuration value') ); else { Configuration::updateValue('MYMODULE_NAME', $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' => 'MYMODULE_NAME', 'size' => 20, 'required' => true ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); $helper = new HelperForm(); // Module, t oken 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['MYMODULE_NAME'] = Configuration::get('MYMODULE_NAME'); return $helper->generateForm($fields_form); } } ?> Is correct ? Moreover I have file : display.php in root folder this module Link to comment Share on other sites More sharing options...
vekia Posted August 28, 2013 Share Posted August 28, 2013 looks well, but the question is: have you got controller named mymoduledisplayModuleFrontController? 'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display'), Link to comment Share on other sites More sharing options...
jbike Posted August 28, 2013 Author Share Posted August 28, 2013 controllers/front/mymoduledisplayModuleFrontController.php <?php class mymoduledisplayModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $this->setTemplate('display.tpl'); } } whether it is this file? Link to comment Share on other sites More sharing options...
vekia Posted August 28, 2013 Share Posted August 28, 2013 that's right, this is this file, so you've got it and it doesnt work? how the url loks like after clickin on "click me" ? Link to comment Share on other sites More sharing options...
jbike Posted August 28, 2013 Author Share Posted August 28, 2013 /index.php?fc=module&module=mymodule&controller=display Link to comment Share on other sites More sharing options...
vekia Posted August 28, 2013 Share Posted August 28, 2013 so everything looks fine, try to change file name to simple "display.php" Link to comment Share on other sites More sharing options...
jbike Posted August 28, 2013 Author Share Posted August 28, 2013 always the same, maybe there is something missing in my main folder or file. tpl is in the wrong place mymodule : - config.xml - mymodule.php - mymodule.tpl - display.tpl - display.php ( I tried to also add it here ) - css - js - img Link to comment Share on other sites More sharing options...
vekia Posted August 28, 2013 Share Posted August 28, 2013 btw. you said that youv'e got this file in: controllers/front/mymoduledisplayModuleFrontController.php you mean /controllers/ directory in root dir of your prestashop installation or modules/mymodule/ directory? Link to comment Share on other sites More sharing options...
jbike Posted August 28, 2013 Author Share Posted August 28, 2013 the 2-nd - modules/mymodule/controllers/front/mymoduledisplayModuleFrontController.php at the beginning I tried to add this to shop/controllers/front/mymoduledisplayModuleFrontController.php Link to comment Share on other sites More sharing options...
vekia Posted August 28, 2013 Share Posted August 28, 2013 modules/mymodule/controllers/front/display.php this is the proper path and filename 1 Link to comment Share on other sites More sharing options...
jbike Posted August 29, 2013 Author Share Posted August 29, 2013 Thanks, I made a mistake, bad completed the display.php file in the path : modules / mymodule / controllers / front. Can I ask for a link or help. How to add value from a query (sql) to my. Tpl? The customer table, I wrote a column balance. I would like to have this value in my module. Link to comment Share on other sites More sharing options...
vekia Posted August 29, 2013 Share Posted August 29, 2013 If your module is based on ObjectModel you can define object fields ($object->variable=value) and after all just use $object->add(); function 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