Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2008, 07:57 PM
Fabsboards Fabsboards is offline
 
Join Date: May 2007
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP code in templates?

The following template is used by a navbar replacement I found on the vbadvanced site.

I'd like to insert PHP code to display different options depending on log in status

So I tried a simple test that would echo some text.

Doesn't work....

What am I doing wrong?

The entire template is below.

---------------------------------------------------------------------------------

<tr>
<td class="thead" align="left">Fab's Boards</td>
<?PHP
echo "This is a test";
?>
</tr>

<tr>
<td class="alt1">
<div class="smallfont"><a STYLE="text-decoration:none" href="http://www.fabsboards.com/cmps_index.php" >Fab's Boards Home</a></div>
<div class="smallfont"><a STYLE="text-decoration:none" href="http://www.fabsboards.com/vbulletin/index.php" >Read All Forums</a></div>
<div class="smallfont">
</td>
</tr>

<tr>
<td class="thead" align="left">Fab's Partner Sites</td>
</tr>

<tr>
<td class="alt1">
<div class="smallfont"><a STYLE="text-decoration:none" href="http://www.fabrocks.com/" >Fab Rocks!</a></div>
<div class="smallfont"><a STYLE="text-decoration:none" href="http://www.byjsohana.com/" >BYJ's Ohana</a></div>
<div class="smallfont"><a STYLE="text-decoration:none" href="http://www.theblueparrot.info/" >The Blue Parrot</a></div>
<div class="smallfont"><a STYLE="text-decoration:none" href="http://www.jimhillmedia.com" >Jim Hill Media</a></div>

<div class="smallfont">
</td>
</tr>
Reply With Quote
  #2  
Old 05-09-2008, 09:07 PM
Farcaster Farcaster is offline
 
Join Date: Dec 2005
Posts: 386
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Unfortunately, or fortunately depending on your perspective, you cannot insert PHP into a vBulletin template.
Reply With Quote
  #3  
Old 05-10-2008, 02:25 AM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to use plugins to perform any logic operations.

See these:
http://www.vbulletin.com/docs/html/plugin_system
http://www.vbulletin.com/docs/html/writing_plugin_code

For your purposes, however, you might be reinventing the wheel. There are dozens of pre-existing variables available for you to use without any additional logic.

Code:
<if condition="$show['member']">
You're logged in.
<else />
You need to log in or register!
</if>
Reply With Quote
  #4  
Old 05-15-2008, 06:23 AM
Fabsboards Fabsboards is offline
 
Join Date: May 2007
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Kirk Y View Post
You need to use plugins to perform any logic operations.

See these:
http://www.vbulletin.com/docs/html/plugin_system
http://www.vbulletin.com/docs/html/writing_plugin_code

For your purposes, however, you might be reinventing the wheel. There are dozens of pre-existing variables available for you to use without any additional logic.

Code:
<if condition="$show['member']">
You're logged in.
<else />
You need to log in or register!
</if>
Can I use the above example with user profile fields?
Reply With Quote
  #5  
Old 05-15-2008, 06:29 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

All user info (for the current user) can be access through the variable $bbuserinfo.
Reply With Quote
  #6  
Old 05-15-2008, 09:50 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you'd like to see a listing of all the data contained within an array, you can use var_dump.

Code:
echo '<pre>';
var_dump($bbuserinfo);
echo '</pre>';

Profile fields can be accessed like so: $bbuserinfo[fieldx], where x is the field id.
Reply With Quote
Reply


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 06:06 PM.


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.03723 seconds
  • Memory Usage 2,212KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete