PDA

View Full Version : PHP code in templates?


Fabsboards
05-09-2008, 07:57 PM
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.

<if condition="$show['member']">
You're logged in.
<else />
You need to log in or register!
</if>

Fabsboards
05-15-2008, 06:23 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.

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


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



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