vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   A bit confused about new hooks calls (https://vborg.vbsupport.ru/showthread.php?t=239311)

HolyKiller 03-28-2010 11:14 PM

A bit confused about new hooks calls
 
Hi, i'm little confused about using template hooks in vB 4, so i just ask here for little help. Hope someone helps me

On vB 3.8.x i had a little server status check in navbar. Template edit was:

Code:

    [ SERVER1 status: $status1 | SERVER2 status: $status2 ]<br />
And used this plugin:

Product: vBulletin
Hook location: global_start
Code:

include "/var/www/mysite.com/misc/serverstatus.php";

$server1=$serverstat1;
$server2=$serverstat2;
$status1="";
$status2="";

if ($server1 == 1) { 
  $status1="<font color=green>ONLiNE</font>"; 
}
else{ 
  $status1="<font color=red>OFFLiNE</font>"; 

if ($server2 == 1) {
  $status2="<font color=green>ONLiNE</font>"; 
}
else{ 
  $status2="<font color=red>OFFLiNE</font>"; 
}

and it looks like: [ SERVER1 status: ONLiNE | SERVER2 status: OFFLiNE ]

But now, on vB 4, it just looks like: [ SERVER1 status: $status1 | SERVER2 status: $status2 ]

So i miss something and i cant figure out what ...


Thanks in advance for help

Holy

HolyKiller 04-16-2010 08:46 AM

Any help please?

DavidsMods 04-16-2010 11:33 AM

You probably haven't registered the variables and used the new variable syntax in the template. Download a vB4 mod and look at how they register variables.

Carnage 04-16-2010 01:02 PM

change $status1 to <vb:var status1> in the template. You'll also need to pre-register them to the navbar.

HolyKiller 04-22-2010 03:48 PM

Thanks, now it is ok, but it ignores html tags :/

My PHP:
Code:

include "/var/www/mysite.com/files/status.php";

$server1=$serverstat1;
$server2=$serverstat2;
$status1="";
$status2="";

if ($server1 == 1) {
  $status1='<font color="green">ONLiNE</font>';
}
else{
  $status1='<font color="red">OFFLiNE</font>';
}
if ($server2 == 1) {
  $status2='<font color="green">ONLiNE</font>';
}
else{
  $status2= '<font color="red">OFFLiNE</font>';
}

vB_Template::preRegister('navbar', array('status1' => $status1));
vB_Template::preRegister('navbar', array('status2' => $status2));


Template mod is:
Code:

    [ SERVER1 status: {vb:var status1} | SERVER2 status: {vb:var status2} ]<br />
<br />
<!-- TwinStar server status - END -->


And it shows as:
[ SERVER1 status: <font color=green>ONLiNE</font> | SERVER2 status: <font color=green>ONLiNE</font> ]

Any ideas?

Thanks

NickyDee 04-23-2010 11:05 PM

The font tag has been deprecated since 1996. Use CSS to achieve the colour effect instead.

HolyKiller 04-24-2010 02:40 PM

Yep, i know and i tried CSS too, but same problem. For example

Code:

if ($server1 == 1) {
  $status1='<div style="color: #00FF00">ONLiNE</div>';
}

give me this: [ SERVER1 status: <div style="color: #00FF00">ONLiNE</div>

So i think, there are some restrictions or something with that var pre-register, because if i use this on normal PHP, everything is fine, so the script is fine.

Lynne 04-24-2010 05:48 PM

What are you using in the template? {vb:raw status1}?

From Wayne's article:
Quote:

VAR - {vb:var variable}
Allows you to output any variable. The output will be processed through htmlspecialchars_uni() to prevent any kind of potential XSS issues.

If your variable outputs HTML code, then you'll want to use raw instead.

RAW - {vb:raw variable}
This will bypass encoding the output to make it safe. This should be used to information that is considered safe and verified in PHP already. An example would be including another template within the current template like the header template. Raw should never be used with user input.

HolyKiller 04-25-2010 10:01 PM

A million thanks for Lynne! That three chars almost killed me. Now it works perfect!

I'll send some Tequilla shots to California ^^


All times are GMT. The time now is 07:09 AM.

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.01074 seconds
  • Memory Usage 1,732KB
  • 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
  • (5)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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