Results 1 to 2 of 2

Thread: if conditional inside php file, how?

  1. #1
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default if conditional inside php file, how?

    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.

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

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

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

    Code:
    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.
    Talk Jesus Forums [ Over 100 Fulfilled Prophecies in the Bible ]
    .....................................................................................
    LogicWeb [ Awesome Web Hosting Since 2004 ]

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    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:

    PHP Code:
    <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 ChatDisabled (?)</span></a></if></if> 
    The other option, if this does not work, is to escape certain of the single quotes, eg
    PHP Code:
    <if condition='in_array($bbuserinfo[\'usergroupid\'], array(2,6,7,35))'

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •