SmartFAQ is developed by The SmartFactory (https://www.smartfactory.ca), a division of InBox Solutions (https://www.inboxsolutions.net)

How can I display different images or include different stylesheets according to the currently viewed module?
The following code snippet will help you to get the directory name of the currently viewed module in your theme.html You have to add the following snippet at the very top of your theme.html in the respective folder (/themes/yourtheme/theme.html). The templates_c folder just compiles the content of the themes folder.
<{php}>
$mod $GLOBALS['xoopsModule'];
$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');
$GLOBALS['xoopsTpl']->assign'xoops_cmod'$dirname );
<{/
php}>
After you have added this (without any changes) you can access the current module directory through the following smarty variable.
<{$xoops_cmod}>
The dirname for the news module is normally "news". So if you are browsing the news module, the variable $xoops_cmod will contain "news". If you are browsing your profile it will contain "system". NOTE FOR XOOPS 2.2.3 (added by Mithrandir): The above code also works on 2.2.3, but is not needed, as <{$xoops_dirname}> is globally available in themes and holds the directory name of the currently selected module - defaulting to "System" With this you can display different images on each module. Just try the following snippet:
<img src="<{$xoops_imageurl}><{$xoops_cmod}>.jpg" alt="" title="" />
$xoops_imageurl is the path to your themes folder. So you have to create a few images there, one for each of your installed modules and an additional one for the system. - system.jpg - news.jpg - newbb.jpg .. and so on. You can also use this variable as a switch for including stylesheets or templates.
<{if $xoops_cmod == "news"}>
    <!-- do 
some stuff here if current module is news -->
<{else}>
    <!-- do 
some stuff for all other situations -->
<{/if}>
This code can be usefull in many situations. But it is up to you, to use this snippet the way you need it.


The comments are owned by the author. We aren't responsible for their content.
Author
Thread
user

 Re: Thanks Chapi!


Quote:

could you use a similar trick to change the block layout on theme.html depending on the current module?

Certainly.

However, I would recommend that removing right hand blocks be done through the blocks administration, setting the right blocks to not show up on forum pages.

 
Top Parent


Login

Who's Online

98 user(s) are online (1 user(s) are browsing XOOPS FAQ)


Members: 0


Guests: 98


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Did you know ?

You can manage the notifications you subscribed to in the Notifications page.

Random question

If I want to participate/help in the development of xoops - who do I talk to about it?