Share » Forums » Setup & design » Is there an eZ way to dynamically...

Is there an eZ way to dynamically include css & js ?

Is there an eZ way to dynamically include css & js ?

Saturday 08 December 2007 1:19:41 am - 2 replies

Author Message

Paul Leclercq

Saturday 08 December 2007 2:51:35 am

Hiya Sébastien,

If you which to dynamically include stylesheets or javascript to your webpage you need to place your stylesheets or javasctpt in the stylesheet or javascript folder of your siteaccess and include them in the override of the design.ini file :
http://ez.no/doc/ez_publish/technical_manual/3_10/reference/configuration_files/design_ini

You can then use the ezini operator to extract the data:
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/data_and_information_extraction/ezini

And you create specifique conditions for each section:
You then place something like this in the override of your page_head.tpl template
for example:

{if $module_result.uri|contains('/myfolder')}
    {def $stylesheets = ezini('StylesheetSettings', 'MyFolderSiteCSS', 'design.ini')}
           {foreach $stylesheets as $stylesheet}
              <link rel="stylesheet" type="text/css" href={"stylesheet"|ezdesign} media="screen" />
           {/foreach}
    {undef $stylesheets}
{/if}

This works in the same way for javascript files. There are probably ways of reducing this but this should work.

Sébastien Antoniotti

Saturday 08 December 2007 3:07:04 am

Thanks for this solution Paul,

Good dev ;)

eZ Publish Freelance
web : http://www.webaxis.fr

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu