PDA

View Full Version : if conditional inside php file, how?



Chadi
10-02-2009, 12:46 AM
I'm trying to use an if conditional inside the skin file for my ipbpro arcade mode.

The problem is when I edit and reupload, I get a blank page due to the code I'm using but I'm not sure where I'm messing up.

In a regular vb template it looks like this.


<if condition="in_array($bbuserinfo['usergroupid'], array(2,6,7,35))">
<if condition="$bbuserinfo['posts'] > 4">
<a href="http://www.talkjesus.com/misc.php?do=page&template=Chat"><span><img src="/images/media-menu/chat.png" alt="Christian Live Chat" class="img-media-menu" />&nbsp;Live Chat</span></a><else /><a href="http://www.talkjesus.com/forum-rules-ten-commandments/53-talk-jesus-10-commandments-rule.html"><span><img src="/images/media-menu/chat.png" alt="Christian Live Chat" class="img-media-menu" />&nbsp;Live Chat: Disabled (?)</span></a></if></if>In the arcade php file, I changed all the " to ' as I know the " does not work apparently.

It looks like this and results in a blank page


<if condition='in_array($bbuserinfo['usergroupid'], array(2,6,7,35))'>
<if condition='$bbuserinfo['posts'] > 4'>
<a href='http://www.talkjesus.com/misc.php?do=page&template=Chat'><span><img src='/images/media-menu/chat.png' alt='Christian Live Chat' class='img-media-menu' />&nbsp;&nbsp;Live Chat</span></a>
<else /><a href='http://www.talkjesus.com/forum-rules-ten-commandments/53-talk-jesus-10-commandments-rule.html'><span><img src='/images/media-menu/chat.png' alt='Christian Live Chat' class='img-media-menu' />&nbsp;Live Chat: Disabled (?)</span></a></if></if>Any one know what I'm doing wrong?

Tried this:


if (in_array($vbulletin->userinfo['usergroupid'], array(2, 6, 7, 35)))
{
<a href='http://www.talkjesus.com/misc.php?do=page&template=Chat'><span><img src='/images/media-menu/chat.png' alt='Christian Live Chat' class='img-media-menu' />&nbsp;&nbsp;Live Chat</span></a>
}
if (in_array($vbulletin->userinfo['$bbuserinfo['posts'] > 4')
{
<a href='http://www.talkjesus.com/forum-rules-ten-commandments/53-talk-jesus-10-commandments-rule.html'><span><img src='/images/media-menu/chat.png' alt='Christian Live Chat' class='img-media-menu' />&nbsp;Live Chat: Disabled (?)</span></a>
}


Results in screenshot
http://pingy.us/?v=1rxr.png

This is the entire portion of that file


function top_links_table($links,$width,$extra) {
global $ibforums;
return <<<EOF
<!-- Media Center Nav -->
<div class="mc_border_out">
<div class="mc_border_in">
<div id="middlebar">
<a href='http://www.talkjesus.com/arcade.php'><span><img src='/images/media-menu/games.png' alt='Arcade Games' class='img-media-menu' />&nbsp;Arcade</span></a>
<a href='http://www.talkjesus.com/journal.php'><span><img src='/images/media-menu/highlight.png' alt='Journals' class='img-media-menu' />&nbsp;Journals</span></a>

if (in_array($vbulletin->userinfo['usergroupid'], array(2, 6, 7, 35)))
{
<a href='http://www.talkjesus.com/misc.php?do=page&template=Chat'><span><img src='/images/media-menu/chat.png' alt='Christian Live Chat' class='img-media-menu' />&nbsp;&nbsp;Live Chat</span></a>
}
if (in_array($vbulletin->userinfo['$bbuserinfo['posts'] > 4')
{
<a href='http://www.talkjesus.com/forum-rules...ents-rule.html'><span><img src='/images/media-menu/chat.png' alt='Christian Live Chat' class='img-media-menu' />&nbsp;Live Chat: Disabled (?)</span></a>
}
<a href='http://www.talkjesus.com/album.php'><span><img src='/images/media-menu/folder.png' alt='Member Albums' class='img-media-menu' />&nbsp;Member Albums</span></a>
<a href='http://www.talkjesus.com/gallery/index.php'><span><img src='/images/media-menu/image.png' alt='Photo Gallery' class='img-media-menu' />&nbsp;Photo Gallery</span></a>
<a href='javascript:openRadioAndTV()'><span><img src='/images/media-menu/multimedia.png' alt='Radio Streaming' class='img-media-menu' />&nbsp;Radio</span></a>
</div>
</div>
</div>
<!-- /Media Center Nav -->
<br />
<table width='100%' border='0' cellspacing='1' cellpadding='4' class="tborder">
<tr>
<td class="tcat" align="center" width="{$width}">{$links}</td>
{$extra}
</tr>
</table>
EOF;
}

Thanks in advance.

forum_amnesiac
10-02-2009, 04:52 AM
Your problem is that if you only change the " to ' then code is interpreted as having 2 opening ' and 2 closing ' inthe first line of code.

To get around this you could do this:


<if condition='in_array($bbuserinfo["usergroupid"], array(2,6,7,35))'>
<if condition='$bbuserinfo["posts"] > 4'>
<a href='http://www.talkjesus.com/misc.php?do=page&template=Chat'><span><img src='/images/media-menu/chat.png' alt='Christian Live Chat' class='img-media-menu' />&nbsp;Live Chat</span></a><else /><a href='http://www.talkjesus.com/forum-rules-ten-commandments/53-talk-jesus-10-commandments-rule.html'><span><img src='/images/media-menu/chat.png' alt='Christian Live Chat' class='img-media-menu' />&nbsp;Live Chat: Disabled (?)</span></a></if></if>

The other option, if this does not work, is to escape certain of the single quotes, eg


<if condition='in_array($bbuserinfo[\'usergroupid\'], array(2,6,7,35))'>