PDA

View Full Version : if statement as replacement variable


imageconstrux
05-04-2009, 06:50 PM
I'm trying to show a welcome message to all users who are not registered or not logged in on forumhome, forumdisplay and showthread. I had originally placed code <if condition="$show['guest']">something</if> in each of the three templates, but for the sake of efficiency should I want to update the welcome message, I assigned that code to a replacement variable.

The if statement evaluated correctly before I moved the code to a replacement variable. But now, it always evaluates the if statement as true, showing the guest welcome message whether logged in or not.

Does the replacement variable system not work with if statements? Or is there something special I need to be doing to make it function correctly?

Lynne
05-04-2009, 07:51 PM
I believe you need to just use valid html in the replacement variables and the condition is not valid html. Maybe just spit out a phrase and then if you want to modify the message, you just modify the phrase.

imageconstrux
05-04-2009, 10:04 PM
Good idea. I shoulda thought of that. :)

--------------- Added 1241478620 at 1241478620 ---------------

Hmm... Nope. That didn't work, either. I end up with html output of $vbphrase[welcome_to_the_x]

Lynne
05-04-2009, 10:46 PM
I mean put the phrase in the condition in the template. Not put the phrase in the Replacement Variable manager.

imageconstrux
05-04-2009, 11:00 PM
That's the weird thing - I didn't put any phrases in.

I changed the code in the templates to:
<if condition="$show['guest']">

<welcome>

</if>

Then I thought I might have been triggering the phrase to come up, so I changed the replacement variable name to <welcomemsg>, but got the same result.

This is too much work. I'll just put the old code back into those three templates and deal with it later if I change the welcome message.

Lynne
05-04-2009, 11:05 PM
I was suggesting you create a phrase, like "welcome_to_my_site". Put your welcome text in there. Then just go:
<if condition="$show['guest']">

$vbphrase[welcome_to_my_site]

</if>

imageconstrux
05-05-2009, 01:00 AM
I'm an idiot.

I just realized the problem was between my ears, not in the code. Your original suggestion worked fine. Thanks for your patience. :)