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"}>
    
<{else}>
    
<{/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

 Thanks Chapi!


A useful add on... thanks for your contribution.

 
Replies
Author
Published
12/28/2004 18:10
11/17/2005 22:25
11/23/2005 10:27
11/23/2005 11:03
        Re: Thanks Chapi!
11/23/2005 11:06
          Re: Thanks Chapi!
11/23/2005 11:27
            Re: Thanks Chapi!
11/23/2005 11:45
              Re: Thanks Chapi!
11/23/2005 12:20
Author
Thread
user

 This looks really interesting


This article is cool & explains a few good techniques. I am wondering if it could help me with my current problem.

I want to display a block (or single line of php code) without the block header on the top of each modules center page. What i mean by this is something like

<h4 id="centerheading"><{$xoops_pagetitle}>h4>


To appear at the very top of every modules center section.

I Have tried to do this by creating a blobk in php mode but dont quite know what to type. i get php exec errors..

any ideas if this is even possible with xoops?

 
Replies
Author
Published
Author
Thread
user

 Not a good suggestion


This suggestion goes against the principle of keeping code separate from presentation, and is also completely unnecessary. If you want module-specific header images, make the changes to the module template!

It is so much easier working with templates that don't contain code - this is a step backwards, in my opinion, negating the benefits that Smarty gives you.

But that's just my opinion, of course

Rowd

 
Replies
Author
Published
01/05/2005 17:45
05/29/2005 14:47
          Re: Not a good suggestion
05/29/2005 16:29
          Re: Not a good suggestion
11/16/2005 0:26
Author
Thread
user

 URL directory instead of module directory?


Very Helpful.

I wonder if there is a way to do this based upon the current directory in the URL instead of the directory for the module ($xoops_cmod).

My concern is, this might limit the header graphic changes to a particular module. If one is using tinycontent, for example, they might want a different graphic to display for various pages... instead of just one for all tinycontent pages.

For example, one might use ModRewrite to make a certain tinycontent page come up when a user types a certain URL.

Which takes me back to the original question. Is there a variable that returns the current directory in the URL instead of the module directory?

Helpful tip, either way. Thanks.

 
Author
Thread
user

 switching style sheets


Quote:

You can also use this variable as a switch for including stylesheets or templates.


Can someone provide the code and location of the code to allow for different style sheets.

 
Replies
Author
Published
01/05/2005 17:30


Login

Who's Online

129 user(s) are online (16 user(s) are browsing XOOPS FAQ)


Members: 0


Guests: 129


more...

Donat-O-Meter

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

Did you know ?

Which folder to upload after unzipping a theme file?

Random question

What are groups and how do I administrate them?