To be perfectly clear :
You have to put your templates in the module's template directory. For back-office templates, in the template/backOffice/default directory. For front-office, in the template/frontOffice/default directory.
Put your assets in one (or more) subdirectory of these directories, using the name you want (assets seems to be convenient ;-)).
\local
\modules
\MyModule
\template
\backOffice
\default
.. your template files ...
\assets
\css
... your css (or less) files ...
\js
... your js files ...
Then, in your templates, use Thelia's assets blocks to generate your assets URLs.
The smarty 'stylesheets ' block returns the absolute URL to one of your CSS assets. The file parameter is the path to your asset file, relative to the current file path :
{stylesheets file='assets/css/mystyle.css'}
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
You can use a "filters" parameter in the stylesheet block, to apply some preprocessing to your CSS files. Available preprocessors are less, sass and compass. Thus, for using a less stylesheet, you'll write :
{stylesheets file='assets/css/my-less-style.less' filters='less'}
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
If you're using several CSS files, use '*' to add them to your template:
{stylesheets file='assets/css/*'}
<link rel="stylesheet" href="{$asset_url}">
{/stylesheets}
As for stylesheets, there's also a javascript Smarty block, for JS files :
{javascripts file='assets/js/myjsdir/myjsfile.js'}
<script src="{$asset_url}"></script>
{/javascripts}
And another one for images :
<img src="{image file="assets/img/myimage.png"}" alt="" />
No filter is currently supported for Javascript and images blocks, but we may add some in the future, like coffee script support or image optimisations.
Last edited by roadster31 (06-03-2014 19:49:19)