Thursday 14 December 2006 3:09:56 am
Hi Claudia, Thanks for your reply, i've done something which works fine, but need certainly to be improved.
i've created : <b>a css file</b> called MyModule.css located in /extension/MyModule/design/standard/stylesheets/MyModule/
<b>an ini file</b> located in /extension/MyModule/settings/MyModule.ini with this code
[StylesheetsSettings]
CSSFile=/extension/MyModule/design/standard/stylesheets/MyModule/MyModule.css
<b>a function in MyModule.php </b> located /extension/MyModule/modules/MyModule/class/ in a php class MyModule MyModule.php contains the class and function of my module.
function MyModuleInit ( $Section, $Var) {
$Value=array();
$MyModuleINI =& eZINI::instance( 'MyModule.ini');
$Value['Value']=$MyModuleINI->Variable($Section, $Var);
return array( 'result' => $Value);
}
This function read MyModule.ini and returns $Value corresponding to parameters $Section and $Var. (yes, yes ... it's seems to be an eZini look like ;-) ) In MyPageLayout.tpl i've just do , between <head>..</head>:
{if ne($ui_component,'content')}
def $Css=fetch( $ui_component, concat($ui_component,'INI',
hash( 'Section', 'StylesheetsSettings',
'Var', 'CSSFile'))}
<style type="text/css">
{foreach $Css as $css}
@import url("{$css}");
{/foreach}
{undef $Css}
</style>
{/if}
The use of $ui_componnent allow me to look for css only if i access MyModule, or a Module which contain a function called ModuleINI ... $ui_component in my case = MyModule otherwise 'content' which is the default ezpublish acces content ... !
<i>
I use only one css file in my module MyModule.
All the Name used in code and file must be MyModule.
In MyModule.ini, you must use StylesheetsSettings and CSSFile
and this work could be certainly used with another Module </i> In MyPageLayout.tpl i can see
<style type="text/css">
@import url("/extension/MyModule/design/standard/stylesheets/MyModule/MyModule.css");
</style>
i hope i'm clear enough (sorry for my english) and thanks for your comments. Patrice
|