Jump to content

need to load template file from prestashop modules


Recommended Posts

Hello, i have theree tpl file in my module like

template1.tpl

template2.tpl

template3.tpl

 

and a mail tpl file for the module like mymodule.tpl

 

From my module i like to load all this template file in my module how can i do this. will there any way to load this tempalate from php code and then send to mail mymodule.tpl

 

or how can i include that in my mymodule.tpl

Link to comment
Share on other sites

Hi there,

You can place those additional tpl in the very same module's folder, and then, in your main file, add {include file="template1.tpl"}. It should work. If it doesn't (since i can't remember if that'd use a relative or absolute path at the moment), In your hook, before displaying the main tpl file, assign the current module's path to a variable, like this:

$this->context->smarty->assign('current_path', $this->_path);

 

And then target it in the template like this {include file="$current_path./template1.tpl"}

 

Hope this helps!

 

Cheers!

Link to comment
Share on other sites

Hi there,

You can place those additional tpl in the very same module's folder, and then, in your main file, add {include file="template1.tpl"}. It should work. If it doesn't (since i can't remember if that'd use a relative or absolute path at the moment), In your hook, before displaying the main tpl file, assign the current module's path to a variable, like this:

$this->context->smarty->assign('current_path', $this->_path);

 

And then target it in the template like this {include file="$current_path./template1.tpl"}

 

Hope this helps!

 

Cheers!

 

hello wen i print $this i got this bellow information

 

 

/* echo "<pre>";

print_r($this);

 

 

[_path:protected] => /theme-presta/modules/smartextrafooter/

[local_path:protected] => /Applications/MAMP/htdocs/theme-presta/modules/smartextrafooter/

*/

 

 

 

then i assing the variable how you told

 

$this->context->smarty->assign(array(

'current_path'=> $this->_path

));

 

and use that in template file like this way

{include file="$current_path./block_twitter.tpl"}

 

but it show me this error.

 

 

Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file '/theme-presta/modules/smartextrafooter/./block_twitter.tpl' in '/Applications/MAMP/htdocs/theme-presta/modules/smartextrafooter//smartextrafooter.tpl'' in /Applications/MAMP/htdocs/theme-presta/tools/smarty/sysplugins/smarty_internal_templatebase.php:127 Stack trace: #0 /Applications/MAMP/htdocs/theme-presta/tools/smarty/sysplugins/smarty_internal_template.php(285): Smarty_Internal_TemplateBase->fetch(NULL, NULL, NULL, NULL, false, false, true) #1 /Applications/MAMP/htdocs/theme-presta/cache/smarty/compile/4ba67c841884f5eef4d769ce4be102189ff5dad4.file.smartextrafooter.tpl.php(46): Smarty_Internal_Template->getSubTemplate('/theme-presta/m...', NULL, NULL, NULL, NULL, Array, 0) #2 /Applications/MAMP/htdocs/theme-presta/tools/smarty/sysplugins/smarty_internal_templatebase.php(180): content_51040e68ab4279_23483457(Object(Smarty_Internal_Template)) #3 /Applications/MAMP/htdocs/theme-presta/classes/module/Module.php(1599): Smarty_Inter in /Applications/MAMP/htdocs/theme-presta/tools/smarty/sysplugins/smarty_internal_templatebase.php on line 127

 

i am using mac and xamp .

can any one know how to solve

Link to comment
Share on other sites

Whoops, sorry, my fault

{include file="{$current_path}block_twitter.tpl"}

 

nothing change after did your way the page do not show when i enable the debug i see

 

Fatal error: Uncaught exception 'SmartyException' with message

'Unable to load template file '/redress/modules/smartextrafooter/block_twitter.tpl' 

in

'I:\EasyPHP-12.1\www\redress/modules/smartextrafooter//smartextrafooter.tpl'

' in I:\EasyPHP-12.1\www\redress\tools\smarty\sysplugins\smarty_internal_templatebase.php on line 127

( ! ) SmartyException: Unable to load template file

 '/redress/modules/smartextrafooter/block_twitter.tpl'

in '

I:\EasyPHP-12.1\www\redress/modules/smartextrafooter//smartextrafooter.tpl'

in

I:\EasyPHP-12.1\www\redress\tools\smarty\sysplugins\smarty_internal_templatebase.php 

on line 127

Call Stack

Edited by smartdatasoft (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

yes that is on that folder didn't you saw that from where two slash '//' comes i don't know. how i think that made the probelm

 

and when without " ./" it gives one slash but not load ?? :(

 

After lots of reasearch i see that this is not work in module end. this work on theme end. suppose you have the file in the template location ex : mytheme/module/extrafooter

then want to include the file it work but if the file on the module page it do not able to load. i think there is some architecture issue on prestashop module file load in smarty. :)

Link to comment
Share on other sites

×
×
  • Create New...