jackads Posted April 9, 2012 Share Posted April 9, 2012 Hi people, I'm new im PrestaShop and in Web Development (PHP), but I already playing with PrestaShop a little... I have a doubt about a thing, I tried to include a file in my module, but it shows a weird error. When I include a file in my module like this: include "file.php"; It works in the PrestaShop page, but it broke the Module Management (back office) page. When I include a file like this: include "../file.php"; This time it works in the back office in Modules page, but now the PrestaShop page broke. If I include in the two ways: include "file.php"; include "../file.php"; Now the two pages works, but it always will show a error message in the header. It's very weird the fact that when a page works another broke, and I cant release a module who will always show a error message to the user, even it working. God bless, thanks for all! Link to comment Share on other sites More sharing options...
Dh42 Posted April 9, 2012 Share Posted April 9, 2012 You cannot include a file that has php code in it. Smarty in prestashop defaulty has the php code turned off. Link to comment Share on other sites More sharing options...
cedricfontaine Posted April 9, 2012 Share Posted April 9, 2012 In your module php file, you could use the following syntax include(dirname(__FILE__). '/file.php'); Link to comment Share on other sites More sharing options...
jorozco Posted January 5, 2015 Share Posted January 5, 2015 For this to work, your directory structure should be (Using PrestaShop 1.6): -- mymodule.php -- views ---- templates ------ hook ------ displayFooBarTemplate.tpl -------- inc ---------- foo.tpl ---------- bar.tpl **Absolute way:** From your main module file: protected function displayFooBarTemplate() { global $smarty; ... $smarty->assign('module_templates', dirname(__FILE__).'/views/templates/'); return $this->display(__FILE__, 'displayFooBarTemplate.tpl'); } then in your tpl file (displayFooBarTemplate.tpl): {include file="{$module_templates}hook/inc/modal/foo.tpl"} {include file="{$module_templates}hook/inc/modal/bar.tpl"} **Relative way (my favorite):** {include './inc/foo.tpl'} {include './inc/modal/bar.tpl'} 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