Not Solved If conditions in templates
#1
Not Solved
Anyone here using the "if" conditions through the vB modifications?

Anyways, I'm trying to use it so I can have a notice shown only to those who haven't activated their accounts yet. I tried
<if condition=$mybb->usergroup['gid']== 5 <then>

TEXT HERE

		<else /></if>	

Anyways, works fine when gid is 1, but not with 5.

Just wondering if anyone else has tried this.
CafeParents.com - Parent-to-Parent discussion forums
Reply
#2
Not Solved
I wish they would add conditional support to templates in 1.4. Eventually this really needs to be done.
Reply
#3
Not Solved
I agree totally.

It's one of the reasons I don't like Coppermine and would move in favor of more integrated solution for MyBB.
CafeParents.com - Parent-to-Parent discussion forums
Reply
#4
Not Solved
i think that it may be due to the space that it doesnt like it, well that happens in some that it is the space that means it doesnt work.
Reply
#5
Not Solved
Let me ask you guys something...

What is the point with <then>?

It doesn't do anything really...

MyBBT has their own Conditional Mod in place and it works fine without the <then> thing.

Btw, we do plan on releasing this. Wink
@ryanashbrook
Do NOT PM me for Support!
Reply
#6
Not Solved
Ryan Ashbrook Wrote:Let me ask you guys something...

What is the point with <then>?

It doesn't do anything really...

MyBBT has their own Conditional Mod in place and it works fine without the <then> thing.

Btw, we do plan on releasing this. Wink

I don't know, dude. I just took the example from other areas (default ones to the modification and theme) and went with it. [shrug]

My knowledge is limited. I take examples, duplicate them and then customize them to my needs.
CafeParents.com - Parent-to-Parent discussion forums
Reply
#7
Not Solved
in inc/functions.php

Find


/**
 * Outputs a page directly to the browser, parsing anything which needs to be parsed.
 *
 * @param string The contents of the page.
 */

add under

// ###################### Start iif #######################
function iif($expression, $returntrue, $returnfalse = '')
{
return ($expression ? $returntrue : $returnfalse);
}
// #############################################


in inc/class_templates.php

find


$template = str_replace("\\'", "'", $db->escape_string($template));

add under

$template= str_replace("<if condition=","\".iif(",$template);
$template= str_replace("<then>",",\"",$template);
$template= str_replace("<else />","\",\"",$template);
$template= str_replace("</if>","\").\"",$template);





code is

<if condition=$mybbuser['uid']== 1 <then>
Other Users <else /> Is User 1 </if>
Reply
#8
Not Solved
The then is there for a reason of course.
using <if condition=$mybbuser['uid']== 1 <then> <whatever_code_should_appear> </if>
returns in php iif($mybbuser['uid'] == 1, <whatever_code_should_appear> );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)