vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   if statement as replacement variable (https://vborg.vbsupport.ru/showthread.php?t=212856)

imageconstrux 05-04-2009 06:50 PM

if statement as replacement variable
 
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
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 [DATE]1241478620[/DATE] at [TIME]1241478620[/TIME] ---------------

Hmm... Nope. That didn't work, either. I end up with html output of
Code:

$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:
Code:

<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:
HTML Code:

<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. :)


All times are GMT. The time now is 01:01 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00964 seconds
  • Memory Usage 1,723KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete