vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   PHP code in templates? (https://vborg.vbsupport.ru/showthread.php?t=178698)

Fabsboards 05-09-2008 07:57 PM

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>

Farcaster 05-09-2008 09:07 PM

Unfortunately, or fortunately depending on your perspective, you cannot insert PHP into a vBulletin template.

Kirk Y 05-10-2008 02:25 AM

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>


Fabsboards 05-15-2008 06:23 AM

Quote:

Originally Posted by Kirk Y (Post 1514511)
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?

Dismounted 05-15-2008 06:29 AM

All user info (for the current user) can be access through the variable $bbuserinfo.

Kirk Y 05-15-2008 09:50 PM

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.


All times are GMT. The time now is 02:36 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.01965 seconds
  • Memory Usage 1,725KB
  • 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
  • (3)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete