1
talunceford
theme design question....smarty variable question...

I am wanting to create an if statement for a theme that im working on for my site, but I'm not sure if the variable that I am using is correct. Basically what I am wanting to do is have and image change based on the module the user is in at the time.

What smarty variable would I use for this? $xoops_url ? or something else?

Basically, I had written the if statement that said <{if $xoops_url == $xoops_url/modules/news}> <use this code> <{else}> <use this code>

Thanks for the help

2
chapi
Re: theme design question....smarty variable question...
  • 2004/5/4 14:17

  • chapi

  • Theme Designer

  • Posts: 611

  • Since: 2002/1/22


You should use this code snippet in your theme.html to get the dirname of the displayed module.

Quote:

<{php}>
$mod = $GLOBALS['xoopsModule'];
$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');
$GLOBALS['xoopsTpl']->assign( 'xoops_cmod', $dirname );
<{/php}>


After this you can access this dirname through the following smarty variable.

Quote:

<{$xoops_cmod}>

3
Stewdio
Re: theme design question....smarty variable question...
  • 2004/5/4 14:23

  • Stewdio

  • Community Support Member

  • Posts: 1560

  • Since: 2003/5/7 1


Could this be done more discretely with an ..include <blah> in the header? I'm not to crazy about adding extra php code to my theme, but I can put this to good use!

4
talunceford
Re: theme design question....smarty variable question...

Sweet, thanks guys for the help. I'll post a screenie or two when I get to that stage....

5
Stewdio
Re: theme design question....smarty variable question...
  • 2004/5/4 14:29

  • Stewdio

  • Community Support Member

  • Posts: 1560

  • Since: 2003/5/7 1


I would love to see how this works in action, I have several non XOOPS custom pages that can take advantage of this

6
DonXoop
Re: theme design question....smarty variable question...

I too am not crazy about PHP code in the theme.html file because some of it is exposed if the file is called directly. However, I use some PHP code myself.

I'm not sure if an include solves the problem. But here is one way to stop prying eyes:
In an .htaccess file in the theme directory or in /themes (so it covers all themes) put:

<Files ~ "theme.html">
Order allow,deny
Deny from all
</Files>

Any direct calls to your theme are now Forbidden.

7
Stewdio
Re: theme design question....smarty variable question...
  • 2004/5/4 14:38

  • Stewdio

  • Community Support Member

  • Posts: 1560

  • Since: 2003/5/7 1


Excellent tip Don!

8
studioC
Re: theme design question....smarty variable question...
  • 2004/5/4 14:41

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


i do it nearly same way like chapi but using other script found here on xoops.org.

With chapis script you get <{$xoops_cmod}> for creativ things in your theme and you can react on actual displayed modules. Use this for changing images or classes.

if modul "news" is diplayed it will be rendered as "news" and so on. With this you are able to create pathes like

<img src="<{$xoops_imageurl}>modul<{$xoops_cmod}>.gif" alt="" title="" />

wich is rendered to : ..
<img src="http://yourtpage.tld/themes/youracutaltheme/modulnews.gif" alt="" title="" />
of course, if modul news is displayed. .. Haven't tried this script but i think this will work like mine, i found here on xoops.org too..

you may put this in header.php but havn't tried...

michael

edit: uups... must hurry giving answers my fingers become elder...

Login

Who's Online

185 user(s) are online (109 user(s) are browsing Support Forums)


Members: 1


Guests: 184


Mamba,

more...

Donat-O-Meter

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

Latest GitHub Commits