vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Conditional in <phrase> (https://vborg.vbsupport.ru/showthread.php?t=189104)

ringleader 08-25-2008 08:42 PM

Conditional in <phrase>
 
I'm trying to replace the username across the forum with a Userfield of my own.

However, I'm running into difficulty with the double quotes (I think).

I'm trying to replace
Code:

$bbuserinfo[username]
with

Code:

<if condition="$bbuserinfo[fieldX]">$bbuserinfo[fieldX]<else />$bbuserinfo[username]</if>
However, many templates use $bbuserinfo[username] in phrases like:
Code:

<phrase 1="$bbuserinfo[username]"></phrase>
Desired result:
Code:

<phrase 1="$bbuserinfo[username]"></phrase>
when $bbuserinfo[fieldX] exists, but
Code:

<phrase 1="$bbuserinfo[fieldX]"></phrase>
when $bbuserinfo[fieldX] exists.

How would I go about replacing my conditional in there, or is it possible at all?

Opserty 08-26-2008 08:09 AM

What have you actually tried in the code then? (What was the output/error if it never worked).

Marco van Herwaarden 08-26-2008 09:07 AM

Why not use:

HTML Code:

<if condition="$bbuserinfo[fieldX]">
<phrase 1="$bbuserinfo[fieldX]"></phrase>
<else />
<phrase 1="$bbuserinfo[username]"></phrase>
</if>


ringleader 08-26-2008 10:04 AM

Quote:

Originally Posted by Opserty
What have you actually tried in the code then? (What was the output/error if it never worked).

I should've included that alright, but it was the usual 'unescaped double quote' type error.

Still, the basis of it was that construct_phrase() couldn't handle a conditional - it needed to be interpreted before it went into <phrase 1=""> etc.

Quote:

Originally Posted by Marco van Herwaarden (Post 1607223)
Why not use:

HTML Code:

<if condition="$bbuserinfo[fieldX]">
<phrase 1="$bbuserinfo[fieldX]"></phrase>
<else />
<phrase 1="$bbuserinfo[username]"></phrase>
</if>


That's the stuff!
I knew there was a way to interpret my phrase or the other phrase in a conditional :D

I'll buy you a pint next time you're in Ireland, guaranteed* ;)

*not a guarantee


All times are GMT. The time now is 01:57 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.00997 seconds
  • Memory Usage 1,724KB
  • 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
  • (5)bbcode_code_printable
  • (2)bbcode_html_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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