Log in

View Full Version : What would this template code look like in php?


fearfx
12-19-2009, 01:49 AM
<if condition="$show['pmstats']">
<div style="font-size: 11px; padding-left: 5px; paddin-top: 5px;"><phrase 1="$vbphrase[unread_x_nav_compiled]" 2="$vbphrase[total_x_nav_compiled]" 3="$session[sessionurl_q]">$vbphrase[private_messages_nav]</phrase></div>
</if>

<if condition="$show['pmwarning']"><div style="font-size: 11px;"><strong><phrase 1="$vbphrase[pmpercent_nav_compiled]">$vbphrase[your_pm_box_is_x_full]</phrase></strong></div></if>

How would I do this in php for a non-vb page?

kh99
12-19-2009, 11:28 AM
Basically,

<if condition="xxx"> some HTML </if> ==> if (xxx) { echo('some HTML'); }

although you have to handle any single quotes and variables that might appear in "some HTML"

<phrase 1="x" 2="y" 3="z">phr</phrase> ==> construct_phrase("phr", "x", "y", "z");

That phrase stuff is a vb function of course, so if you're not using any vb you could just build a string instead.

fearfx
01-12-2010, 07:15 PM
if ($show['pmstats']) {
construct_phrase("phr", $vbphrase['unread_x_nav_compiled'], $vbphrase['total_x_nav_compiled'], $session['sessionurl_q']);
echo '<div style="font-size: 11px; padding-left: 5px; padding-top: 5px;"><phrase 1="'.$vbphrase['unread_x_nav_compiled'].'" 2="'.$vbphrase['total_x_nav_compiled'].'" 3="'.$session['sessionurl_q'].'">'.$vbphrase['private_messages_nav'].'</phrase></div>';
}


does this look right, cuz it sorta works.

it outputs: Private Messages: %1$s, %2$s.

instead of: Private Messages: Unread 0, Total 92.

kh99
01-13-2010, 10:50 PM
I'm sorry, I guess my example wasn't clear, it was supposed to be showing you how I thought a template with a phrase could be changed to php code, but "phr" shouldn't be used literally, it was just meant to stand for any phrase. And ==> means 'gets replaced with', so your resulting php code shouldn't contain the <phrase> tags.