1
russtik
Smarty logic help needed
  • 2005/2/22 17:12

  • russtik

  • Just popping in

  • Posts: 70

  • Since: 2004/8/13


Hello all,

I'm working on a theme where I've removed the <{$xoops_contents}> tag and placed it in a separate template. The problem I am currently having is controlling when this gets displayed. I don't want this to be called when there is no module to display i.e. the home page. I've been experimenting with some variations around this:

<{if $thisPage == "system"}>
    <{echo 
"";}>
  <{else}>
    <{include 
file="default/theme_contentcenter.html"}>
  <{/if}>


This hasn't worked, it includes the template regardless. I'm only really stabbing the in dark, I don't even know if the syntax is right. Can anyone help shed some light onto this quandry?

Also:

In the template I've made (referenced above), I've used the <{$module.name}> tag for a title, but it only every returns 'Contact Us' in the browser irrespective of what module you're actually in. Anyone know why this might be?

TIA

2
ejuden01
Re: Smarty logic help needed
  • 2005/2/22 17:25

  • ejuden01

  • Not too shy to talk

  • Posts: 121

  • Since: 2004/4/5 1


Hello russtik,

I believe you are right about having problems with your smarty syntax. The correct syntax should be:

<{if $thisPage eq "system"}>

Here is a link for some smarty help: if,elseif,else

3
rowdie
Re: Smarty logic help needed
  • 2005/2/22 17:25

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


Try this:

<{if $xoops_contents}>
  <{include 
file="default/theme_contentcenter.html"}>
<{/if}>

4
Mithrandir
Re: Smarty logic help needed

<{echo xxx}>
is not a Smarty syntax since everything you put outside the <{ }> tags is sent to the output buffer uninterpreted

are you setting $thisPage anywhere? otherwise you cannot use it in a Smarty template

<{$module.name}> is set by the main menu block - I'm guessing that Contact Us is the last item in the main menu list?

To get the functionality, you want, try this:
<{php}>
if isset(
$GLOBALS['xoopsModule']) && is_object($GLOBALS['xoopsModule']) {
<{/
php}>
    <{include 
file="default/theme_contentcenter.html"}>
<{
php}>
}
<{/
php}>

5
Mithrandir
Re: Smarty logic help needed

Quote:

ejuden01 wrote:
Hello russtik,

I believe you are right about having problems with your smarty syntax. The correct syntax should be:

<{if $thisPage eq "system"}>

Here is a link for some smarty help: if,elseif,else


== works just as well as eq - just like !=, >, < etc. all work

eq, ne, neq, gt etc. are optional alternatives

6
rowdie
Re: Smarty logic help needed
  • 2005/2/22 17:43

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


Mith, I thought you were against having php tags in templates

What's wrong with keeping it simple, and just checking the $xoops_contents variable, as per my previous post?

<{if $xoops_contents}>
<{include file="default/theme_contentcenter.html"}>
<{/if}>

7
Mithrandir
Re: Smarty logic help needed

I am deeply against them.

I hadn't thought about your solution, which I think is better - you just posted while I was writing.

8
russtik
Re: Smarty logic help needed
  • 2005/2/22 17:55

  • russtik

  • Just popping in

  • Posts: 70

  • Since: 2004/8/13


None of these approaches have worked I'm afraid.

Tried:

<{if $module eq 'system'}>
    <{
php}>echo "";<{/php}>
  <{else}>
    <{include 
file="default/theme_contentcenter.html"}>
  <{/if}>


and

<{if $xoops_contents}>
<{include 
file="default/theme_contentcenter.html"}>
<{/if}>


...to no avail

Mithrandir's suggestion produced a blank white page.

9
rowdie
Re: Smarty logic help needed
  • 2005/2/22 18:05

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


Mine works for me, I tested before I posted it.

I think the problem must be the linked file. Try using the complete url :

<{if $xoops_contents}>
<{include file="<{$xoops_imageurl}>default/theme_contentcenter.html"}>
<{/if}>

That's provided you have a folder called "default" in your theme folder. If the included file is in the root of your theme folder then use: <{$xoops_imageurl}>theme_contentcenter.html


In fact, if the included file doesn't exist at the location you've given, that would explain the blank page you get with Mith's solution.

Rowd

10
russtik
Re: Smarty logic help needed
  • 2005/2/22 18:18

  • russtik

  • Just popping in

  • Posts: 70

  • Since: 2004/8/13


Rowdie,

Your suggestion works as far as excluding the template from the homepage, but upon navigating to a module it chokes. Taking a look at the source of the rendered page shows that it just stops at the point where I pasted your code.

Login

Who's Online

361 user(s) are online (258 user(s) are browsing Support Forums)


Members: 0


Guests: 361


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