Welcome to the THELIA support and discusssion forum


Rejoignez la communauté sur le Discord Thelia :


Hi everyone,

Since I my knowledge in french is not that advanced, I moved to the english part of this form for my question.
I have some trouble with my assets that are located in a module.
The assets map contians CSS, image and JavaScript files.
The first two (CSS and Images) are moved correctly to my web folder on page navigation, but the last type (Javascript) just stays in the map.
This is the folder structure in my module:

The javascript is included by used the following code
<script type="text/javascript" src="/assets/frontOffice/default/<somemodule>/js/script.js"></script>

The path wich is set in my template for the resources is correct since it works for the CSS and Images.
I'm not sure if this is a bug or I missed some configuration (?).
(PS: the documentation is not that advanced on modules and their assets).
Hope someone can help me with this problem.
Thanks in advance.



for Css you need use come this example :

{stylesheets file='assets/css/responsive.css'} <!-- folder to you css -->
        <link rel="stylesheet" href="{$asset_url}">

for Js you need use come this example :

{javascripts file='assets/js/myscript.js'}  <!-- folder to you js -->
    <script src="{$asset_url}"></script>


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 ;-)).

           .. your template files ...
             ... your css (or less) files ...
             ... 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}">

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

If you're using several CSS files, use '*' to add them to your template:

{stylesheets file='assets/css/*'}
        <link rel="stylesheet" href="{$asset_url}">

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>

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)

OpenStudio Toulouse


Thanks for the response.
After trying to get it working for a while, I saw that the path is not relative to the template I'm using it in.
I expect the path to be: <root>/local/modules/<modulename>/templates/frontOffice/default/assets/css/style.css.
Although on runetime it's refering to <root>/templates/frontOffice/default/assets/css/style.css.

Due this problem the files I want to load are not found.
I guess I need to add a reserved variable like {$smarty.current_dir}?

Thanks in advance

After going through some other plugins I found that you can set the source for the CSS and JS tag.
That fixed the issue discribed above.

Last edited by rhermans (07-03-2014 09:41:44)


After going through some other plugins I found that you can set the source for the CSS and JS tag.
That fixed the issue discribed above.

Oops. Sorry, I forgot to mention the source parameter, that should be used to load the module assets:

{stylesheets file='assets/css/mystyle.css' source='MyModule'}
        <link rel="stylesheet" href="{$asset_url}">

Use source="name_of_your_module" to load an asset from the module template.

If "source" is not present, the main template path is used to generate the asset path.

OpenStudio Toulouse