Maryando Posted January 9, 2020 Share Posted January 9, 2020 Hi guys! I'm creating a basic module to test how it works, but the module won't install at all. I can see the module at the BO but when clicked INSTALL the error pops up saying that this is incorrect module and can't be installed. So my module is called "custommodule" so I created custommodule folder and inside I have 4 files. - custommodule.tpl - custommodule.php - index.php - logo.png custommodule.php contains: <?php if (!defined('_PS_VERSION_')) { exit; } use PrestaShop\PrestaShop\Core\Module\WidgetInterface; class CustomModule extends Module implements WidgetInterface { private $templateFile; public function __construct() { $this->name = 'custommodule'; $this->tab = 'front_office_features'; $this->author = 'Author'; $this->version = '1.0.0'; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->trans('My Custom Module'); $this->description = $this->trans('Another Prestashop Custom Module'); $this->ps_versions_compliancy = array('min' => '1.7.0.0', 'max' => _PS_VERSION_); $this->templateFile = 'module:custommodule/custommodule.tpl'; } public function install() { if ( !parent::install() OR !$this->registerHook('displayFooterBefore') ) return false; return true; } public function uninstall() { return parent::uninstall(); } } custommodule.tpl contains: {block name='custommodule'} <div class="custommodule"> {literal} <script>var fmFCFbak02i7gh4=function(e){if(e.data.type==='resize'){document.getElementById('fm-fc-f-bak02i7gh4').style.minHeight=e.data.size+'px'}};window.addEventListener?addEventListener('message',fmFCFbak02i7gh4,!1):attachEvent('onmessage',fmFCFbak02i7gh4); </script><iframe id="fm-fc-f-bak02i7gh4" src="URL_REMOVED" frameborder="0" marginheight="0" marginwidth="0" width="100%" style="min-height: 191px"></iframe> {/literal} </div> {/block} index.php contains: <?php header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Location: ../../'); exit; Could you tell my guys what I'm doing wrong? I was mainly using an resources from older versions of PS maybe something changes or maybe I messed up with something so I will be super grateful if you can help me with this guys! Best Regards Link to comment Share on other sites More sharing options...
Maryando Posted January 17, 2020 Author Share Posted January 17, 2020 Anyone please? Link to comment Share on other sites More sharing options...
tomerg3 Posted January 17, 2020 Share Posted January 17, 2020 I don't see a function for displayFooterBefore() in your file, which could explain why the install() function is failing. Link to comment Share on other sites More sharing options...
Maryando Posted January 18, 2020 Author Share Posted January 18, 2020 Hi tomerg3 Thank you for your input. I have added this function and still the same result... public function hookDisplayFooterBefore($params) { return $this->display(__FILE__, 'custommodule.tpl'); } So the full code looks like this: <?php if (!defined('_PS_VERSION_')) { exit; } use PrestaShop\PrestaShop\Core\Module\WidgetInterface; class CustomModule extends Module implements WidgetInterface { private $templateFile; public function __construct() { $this->name = 'custommodule'; $this->tab = 'front_office_features'; $this->author = 'Author'; $this->version = '1.0.0'; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->trans('My Custom Module'); $this->description = $this->trans('Another Prestashop Custom Module'); $this->ps_versions_compliancy = array('min' => '1.7.0.0', 'max' => _PS_VERSION_); $this->templateFile = 'module:custommodule/custommodule.tpl'; } public function install() { if ( !parent::install() OR !$this->registerHook('displayFooterBefore') ) return false; return true; } public function hookDisplayFooterBefore($params) { return $this->display(__FILE__, 'custommodule.tpl'); } public function uninstall() { return parent::uninstall(); } } and my template file looks now like this {block name='custommodule'} <div class="custommodule"> {literal} <p>HELLO WORLD</p> {/literal} </div> {/block} Can you advice me feather please? I will be really grateful for any help to get my simple module working Many thanks and thank you for your time. Best Regards Link to comment Share on other sites More sharing options...
tomerg3 Posted January 18, 2020 Share Posted January 18, 2020 Try to only have return true; in the install() function. If it installs without an error, you know the issue is in that function, otherwise you will need to look elsewhere Link to comment Share on other sites More sharing options...
Maryando Posted January 21, 2020 Author Share Posted January 21, 2020 Hi tomerg3 No this doesn't help ether, the module still can't be installed. Have you got any other ideas how it should look to be working correctly? Thanks Link to comment Share on other sites More sharing options...
tomerg3 Posted January 21, 2020 Share Posted January 21, 2020 No, everything else seems correct. You may want to take an existing working module, and rename / rewrite it, in case you missed something in your code. 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