Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 10-01-2009, 08:59 PM
Chadi's Avatar
Chadi Chadi is offline
 
Join Date: May 2004
Location: USA
Posts: 2,043
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
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?
Reply With Quote
  #2  
Old 10-01-2009, 10:11 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 10-01-2009, 10:24 PM
Chadi's Avatar
Chadi Chadi is offline
 
Join Date: May 2004
Location: USA
Posts: 2,043
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Attached Images
File Type: jpg 1.jpg (8.9 KB, 0 views)
Reply With Quote
  #4  
Old 10-01-2009, 10:51 PM
Chadi's Avatar
Chadi Chadi is offline
 
Join Date: May 2004
Location: USA
Posts: 2,043
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;
}
Reply With Quote
  #5  
Old 10-01-2009, 11:21 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 10-01-2009, 11:42 PM
Chadi's Avatar
Chadi Chadi is offline
 
Join Date: May 2004
Location: USA
Posts: 2,043
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 10-02-2009, 12:51 AM
Digital Jedi's Avatar
Digital Jedi Digital Jedi is offline
 
Join Date: Oct 2006
Location: PopCulturalReferenceLand
Posts: 5,171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;
Reply With Quote
  #8  
Old 10-02-2009, 12:59 AM
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Posts: 4,141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Reply With Quote
  #9  
Old 10-02-2009, 01:09 AM
Chadi's Avatar
Chadi Chadi is offline
 
Join Date: May 2004
Location: USA
Posts: 2,043
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;
}
Reply With Quote
  #10  
Old 10-02-2009, 01:16 AM
Digital Jedi's Avatar
Digital Jedi Digital Jedi is offline
 
Join Date: Oct 2006
Location: PopCulturalReferenceLand
Posts: 5,171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04879 seconds
  • Memory Usage 2,290KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete