Include other .tpl in a .tpl file Prestashop - smarty

I'm usinh a Prestashop 1.5.4.1, and I would like to call a module in other module (precisely I need to use slider module just above the home featured products). I tried to call it via
include file='../directory/module.tpl'
but always I get only blank page without any code. I also tried with different ways of directory statement, but always the result was the same. Is there any possibility to include new module in correct way?

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'}

What worked for me in Prestashop 1.6 is
{include file="$tpl_dir/modules/blocknewsletter/blocknewsletter.tpl"}
I put this in the footer.tpl file and correctly displayed the text box for subscribing to the newsletter. I suppose it works for all other modules, too.

Proper way to include a smarty tag includes using the curl brackets.
{include file='directory/module.tpl'}
Note that the directory in the include statement should be relative to the templates directory.
http://www.smarty.net/docsv2/en/language.function.include.tpl

In your php code declare a variable like this :
$this->path_to_tpl_folder = str_replace('\\', '/', _PS_MODULE_DIR_) . 'mon_module/tpl';
$this->context->smarty->assign('tpl_path', $this->path_to_tpl_folder)
Then in your smarty template :
{include file=$tpl_path/my_file.tpl}
Compatible with Prestashop 1.4 and 1.5.

Related

How to change the content of Variables called in Template file of Prestashop

banners.tpl files code snippet
{if !empty($banner.html)}
<div class="custom-html">
{$banner.html nofilter}{* can not be escaped *}
</div>
{/if}
How can I change the content of $banner.html variable?
You have to find the .php file whose display banners.tpl
then, analyse variables are assign to smarty and change it !

Laravel 5 Elixir source and output pathing

I'm having trouble understanding Laravel 5's elixir pathing. In my project, I have multiple css files (bootstrap, plugins, theme etc) and javascript files stored under:
resources/assets/css/<my css files>
resources/assets/js/<my javascript files>
I simply want to combine and version all styles and scripts and place them in my public directory. I believe the default output directly is:
public/build/css/app-xxxxxxxx.css
public/build/js/app-xxxxxxxx.js
(Where xxxxxxxx is the checksum using the version method)
What should my gulpfile.js look like to achieve this? Thanks!
You can use full path on the name or set the third parameter as default path. Examples (works with scripts or css):
mix.stylesIn('resources/assets/css', 'public/css/all.css');
Since there is a bug where you can't use the output of a somethingAll to concatenate with something else, I use this instead (note the wildcard):
mix.scripts(['maskedinput.js',
'blockui.js',
'user/*.js'],
'public/js/user.js', 'resources/assets/js/');
First parameter is the input files, second is the output file, third is the input's default path.
To version just call it on the file path.
mix.version("public/js/user.js");

Blade templating

Is it possible to have the master.blade.php file outside of the template files.
Example below:
views/
master.blade.php
layout/
hello.blade.php
views/layout/hello.blade.php
#extends('layout.master)
I have tried the above but it cannot find the master.blade.php file. So is there a way to refer to a directory above the blade file.
it would be
#extends('master')
the "." in the view names indicate folders. so
#extends('my.long.path.to.template')
would be found in:
/views/my/long/path/to/template.blade.php
layouts don't have to be in a folder called layouts

Is it possible to use include file as variable within include file

Is it possible to use an include file call as a variable within an include file call?
Below is an example of what I need:
{include file="data/data.inc.tpl" opts="{include file="data/dataset.inc.tpl"}"}
So the information from dataset.inc.tpl is used as a variable to display various options from data.inc.tpl
No, but you can capture the contents of the include in a variable:
{capture name=dataset}
{include file="data/dataset.inc.tpl"}
{/capture}
{include file="data/data.inc.tpl" opts=$smarty.capture.dataset}
or pass the file name to be included
{include file="data/data.inc.tpl" opts='data/dataset.inc.tpl'}
and then in data.inc.tpl...
{capture name=dataset}
{include $opts}
{/capture}

When using Webby/Compass Integration what directory do the *.sass files go in?

I just setup Webby/Compass integration.
(https://github.com/Compass/compass/wiki/webby-integration)
Where do I put my Compass/Sass source files, and in what directory do they get
output as stylesheets?
You can put your SASS files wherever you want (under the 'content/' directory). So if the directory containing your CSS files is 'content/css', then put them there.
The only important thing is that you set the metadata part correctly, at the top of the SASS file itself. Like this:
$ cat content/css/site.sass
---
filter: sass
extension: css
layout: nil
---
[..cut..]
It looks like you can set the source-file yourself, from the documentation:
Compass.configuration do |config|
config.project_path = File.dirname(__FILE__)
config.sass_dir = File.join('src', 'stylesheets' )
end
It looks like it defaults to "src/stylesheets". When you build it it will probably get rendered to "output/css/" but I never used webby myself so im not 100% sure.
Okay found it in this repository
Apparently it belongs in the ./content/stylesheets directory of your webby project, and is output to the ./output/stylesheets directory.
What perplexes me is "why" it works this way. Why File.join? It looks like the default "src" is being replaced by "stylesheets" rather than joining a new string. Curious.

Resources