1
LionHeart
theme page selection
  • 2006/10/18 1:00

  • LionHeart

  • Just popping in

  • Posts: 70

  • Since: 2005/5/14


I'm trying to set my theme so that when any of header-menu (across the top) modules are selected, the theme goes to 'theme_other.html', but any other time, stays in 'theme_main.html'.

Looking over the theme.html file, I see this;

<{if $xoops_pagetitle == News}>
    <{include 
file="Classic/theme_main.html"}>
<{else}>
    <{include 
file="Classic/theme_other.html"}>
<{/if}>


Can anyone show me how I change the statement to look something like this, instead;

<{if $xoops_pagetitle == Forums}>
    <{include 
file="Classic/theme_other.html"}>
<{if 
$xoops_pagetitle == Library}>
    <{include 
file="Classic/theme_other.html"}>
<{if 
$xoops_pagetitle == Gallery}>
    <{include 
file="Classic/theme_other.html"}>
<{if 
$xoops_pagetitle == Journals}>
    <{include 
file="Classic/theme_other.html"}>
<{else}>
    <{include 
file="Classic/theme_main.html"}>
<{/if}>


I know the above change doesn't work , but that's essentially what I'm trying to get to. Can anyone show me what the code should look like, to get there?

In advance, thanks!

2
JMorris
Re: theme page selection
  • 2006/10/18 3:30

  • JMorris

  • XOOPS is my life!

  • Posts: 2722

  • Since: 2004/4/11


If I'm understanding you correctly, a variation of the following should work...
<{if $xoops_requesturi != "/modules/mydownloads/"}>
    <{include 
file="Classic/theme_main.html"}>
<{else}>
    <{include 
file="Classic/theme_other.html"}>
<{/if}>

The != is equivalent to "does not", therefore, anything that does not match the string will match the else statement.

You can use the Smarty Templates Debug in your general settings to find out all the variables the are available to you. I've found that they are very handy when I want to change certain design features on a per module basis.

Hope that helps.

Best Regards,

James
Insanity can be defined as "doing the same thing over and over and expecting different results."

Stupidity is not a crime. Therefore, you are free to go.

3
LionHeart
Re: theme page selection
  • 2006/10/18 13:56

  • LionHeart

  • Just popping in

  • Posts: 70

  • Since: 2005/5/14


Hi James,

The ! parameter is good to know, it may come in handy, but in this case I think it puts me back where I started from, only reversed.

I have 4 exclusion statements that I wish to insert in the IF statement, and then all ELSE goes to main. What I need to figure out is how to have all 4 of them in place. I'll explain the layout, maybe that will make more sense;

In the template header menu (across the top), there are 5 options. 1 is for the Main menu. The other 4 are the Forums, Library, Gallery, Journals. These other 4 options are full-screen display modules, no left or right side blocks, and the template is different to make that work correctly.

However, in the Main menu, there should not only be the News module, but the Polls, Guestbook, Downloads, Links, etc (all are small-display modules), all of which should display in the Main menu (Main menu retains left and right side blocks).

The way it is now, everything except the News will go to the full-screen display. The only modules which that should happen to are the 4 options in the header menu.

Is there a way to have 4 parameters in the IF exclusion statement?

Something like;

<{if $xoops_pagetitle == ForumsLibraryGalleryJournals}>
    <{include 
file="Classic/theme_other.html"}>
<{else}>
    <{include 
file="Classic/theme_main.html"}>
<{/if}>

4
LionHeart
Re: theme page selection
  • 2006/10/18 14:31

  • LionHeart

  • Just popping in

  • Posts: 70

  • Since: 2005/5/14


I found the answer!

In case others need to do something similar, I'll post it here. It's the use of the ELSEIF statement. It looks like this, in the theme.html;

<{if $xoops_pagetitle == Forums}>
    <{include 
file="Classic/theme_other.html"}>
<{elseif 
$xoops_pagetitle == Journals}>
    <{include 
file="Classic/theme_other.html"}>
<{elseif 
$xoops_pagetitle == Library}>
    <{include 
file="Classic/theme_other.html"}>
<{elseif 
$xoops_pagetitle == Gallery}>
    <{include 
file="Classic/theme_other.html"}>
<{else}>
    <{include 
file="Classic/theme_main.html"}>
<{/if}>


This directs my full-width modules to the full-width theme_other.html, while everything else goes to my page with side-blocks eating up some of the screen real estate, on theme_main.html. ELSEIF creates as many options or alternative theme layouts as I need.

5
JMorris
Re: theme page selection
  • 2006/10/18 16:32

  • JMorris

  • XOOPS is my life!

  • Posts: 2722

  • Since: 2004/4/11


Another option is to use the OR (can be used as "OR" or "|") statement...
<{if $xoops_requesturi == "/modules/mydownloads/" "/modules/newbb/" "/modules/news/" "/modules/gallery/"}>
    <{include 
file="Classic/theme_other.html"}>
<{else}>
    <{include 
file="Classic/theme_main.html"}>
<{/if}>


Effectively, it does the same thing as the elseif, but with less code. It also allows you to change your page titles without worrying about updating your custom code.

HTH.

James
Insanity can be defined as "doing the same thing over and over and expecting different results."

Stupidity is not a crime. Therefore, you are free to go.

6
LionHeart
Re: theme page selection
  • 2006/10/18 18:37

  • LionHeart

  • Just popping in

  • Posts: 70

  • Since: 2005/5/14


Hi James,

That's a really good point regarding the page titles, they can change when you drill down into some of the module options, and then the theme dumps back into the theme_main.html, which is no good.

I looked for the variable you used on the http://xoops-tips.com/news-article.storyid-12.htm site, but didn't see it.

$xoops_requesturi


Is that from a non-english language file? And if so, I can I use it in an english template? Or is there another name for it? I tried to use it exactly as you typed it, and it didn't work (I also tried 'requesturl' in case that was a typo, but it didn't do anything at all).

7
JMorris
Re: theme page selection
  • 2006/10/18 23:09

  • JMorris

  • XOOPS is my life!

  • Posts: 2722

  • Since: 2004/4/11


Ah! that was a typo on my part. Here's a snippit of code from an actual live site...
<{if $xoops_dirname == 'newbb' || $xoops_requesturi == '/edituser.php' || $xoops_requesturi == '/register.php' || $xoops_dirname == 'chat'}> 
    <
td id="singlecol">
    <{else}> 
    <
td id="leftcol">
    <{/if}>

Basically, if any one of the conditions are met (OR statement), then td id="singlecol" is used, else td id="leftcol" is used. This is how I dynamically remove the left column of a theme without going through the headache of setting the block settings for each module in XOOPS Admin.

The above is a compound statement that makes use of two Smarty functions, explained below.

$xoops_dirname refers to /modules/dirname/
$xoops_requesturi refers to path/file.php

These functions are closely akin to PHP functions. In fact, with a little bit of research on the Smarty Website and the PHP website, you will find that many of the conditional statements in PHP can be applied in Smarty, just in a friendlier syntax. The $xoops_ portion of the code just indicates that the code is incorporated in the XOOPS custom Smarty classes.

I'm far from a coder, just cleaver with duct tape and bubble gum , so if there is a coder out there that can explain the above better, by all means, please do.

HTH.

James
Insanity can be defined as "doing the same thing over and over and expecting different results."

Stupidity is not a crime. Therefore, you are free to go.

8
LionHeart
Re: theme page selection
  • 2006/10/19 2:51

  • LionHeart

  • Just popping in

  • Posts: 70

  • Since: 2005/5/14


James... Thank you. Very much. I'm not a coder either, still blaming it on the trauma I suffered from not being able to get a 3-line 'hello world' program to work with the data-corrupted Atari ST Basic disc years ago, lol. After much trial and error, I finally got it figured out and it's working perfectly in moving to the proper template for the given module, and staying there when I drill down.

What I wasn't understanding was that I had to specify the variable in each OR statement. This is what it finally came down to;

<{if $xoops_dirname == 'newbb' || $xoops_dirname == 'smartsection' || $xoops_dirname == 'myalbum' || $xoops_dirname == 'popnupblog'}>
    <{include 
file="Classic/theme_other.html"}>
<{else}>
    <{include 
file="Classic/theme_main.html"}>
<{/if}>


I really appreciate your patience and support, James, thank you once more.

Now I can move on to fixing the next problem!

Login

Who's Online

208 user(s) are online (129 user(s) are browsing Support Forums)


Members: 0


Guests: 208


more...

Donat-O-Meter

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

Latest GitHub Commits