PDA

View Full Version : Template issues


Khoori7
01-31-2014, 07:41 PM
I'm trying to add this into my template...

<?php
echo file_get_contents("http://site.net/site/onlineplayers.php"); ?>
there are [..] online</font></p>
<br>

but.. i get this.

https://vborg.vbsupport.ru/external/2014/01/2.png

It's not showing the text any way to do this? I'm trying to get the number from that page

it works fine if i just add that code into a .php file.

squidsk
01-31-2014, 07:43 PM
You can't add php code into a template. You can only run php code from a hook or from a php file.

Khoori7
01-31-2014, 08:18 PM
Mind giving me an example?

kh99
01-31-2014, 08:40 PM
How does that code work? I guess the number of players online is supposed to appear in place of [..], but I've never seen that before.

Anyway, in a plugin you'd do something like:
$players_online = file_get_contents("http://site.net/site/onlineplayers.php");
vB_Template::preRegister('template', array('players_online' => $players_online));


then in your template you'd use something like:
there are {vb:var players_online} online

You'd have to change 'template' to the actual template you're putting that in, and the plugin "hook location" would depend on which template you're using (although you could use parse_templates to start with).