vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   if conditional inside php file, how? (https://vborg.vbsupport.ru/showthread.php?t=224367)

Chadi 10-01-2009 08:59 PM

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?

Lynne 10-01-2009 10:11 PM

If it's php, you can't use template conditions - you need to use actual php code. For instance:
PHP Code:

if (in_array($vbulletin->userinfo['usergroupid'], array(26735)))
{
stuff


You can look in the vbulletin php files for other examples and in the manual also.

Chadi 10-01-2009 10:24 PM

1 Attachment(s)
Thanks Lynne.

What about this one?

<if condition="$bbuserinfo['posts'] > 4">

Is this the correct replacement?

if (in_array($vbulletin->userinfo['bbuserinfo['posts'] > 4')

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...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>
}

Results in screenshot

Chadi 10-01-2009 10:51 PM

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;
}


Lynne 10-01-2009 11:21 PM

I think it will work with posts, but I'm not sure. You'll have to see if it's been formatted at the point that you go to use it.

You also cannot go in and out of html/php like you are doing. You may want to read up on using html in a php page and how to end your php and go into html and vice-versa.

Chadi 10-01-2009 11:42 PM

Can anyone else help me please?

I'm not a coder, so I have no idea how to really go about this and I tried looking at other default vb files for hints, not picking up on how it works.

Digital Jedi 10-02-2009 12:51 AM

I've not fooled around with it too much and I only understand a little about it, but I know you can't jumble your HTML and PHP together like you have. Take a look at the one of the skin files for ibProArcade and take note of where HTML is being placed and how. Take note of how only variables are being used within the HTML and how it stands out from the code structure of PHP. For instance, if conditions are not being used inside of return <<<EOF EOF;

HMBeaty 10-02-2009 12:59 AM

Try something like this...
PHP Code:

if (in_array($vbulletin->userinfo['usergroupid'], array(26735)) AND $vbulletin->userinfo[posts] > 4)
{
    do 
something
}
else
{
    do 
something else



Chadi 10-02-2009 01:09 AM

I tried your method HM and got this

http://pingy.us/?v=box.png

The code
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)) AND $vbulletin->userinfo[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...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;
}

This method below (the way I had it originally) works just fine, but I really want the if conditionals in place for enhanced security against trouble makers.

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>
<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>
<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;
}


Digital Jedi 10-02-2009 01:16 AM

I'm not entirely sure what your trying to do, but why not just use the standard vBulletin conditionals in the ARCADE template? Then you can set up an <else> in the conditional with a message or whatever else you want those usergroups to see. Seems like that would be easier and closer to what your trying to accomplish.


All times are GMT. The time now is 07:02 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.01440 seconds
  • Memory Usage 1,786KB
  • 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
  • (6)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete