vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Template issues (https://vborg.vbsupport.ru/showthread.php?t=307771)

Khoori7 01-31-2014 07:41 PM

Template issues
 
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:
Code:

$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:
Code:

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


All times are GMT. The time now is 06:13 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.00922 seconds
  • Memory Usage 1,712KB
  • 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
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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