Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2010, 11:14 PM
HolyKiller HolyKiller is offline
 
Join Date: Dec 2006
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 04-16-2010, 08:46 AM
HolyKiller HolyKiller is offline
 
Join Date: Dec 2006
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any help please?
Reply With Quote
  #3  
Old 04-16-2010, 11:33 AM
DavidsMods DavidsMods is offline
 
Join Date: Oct 2009
Posts: 134
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 04-16-2010, 01:02 PM
Carnage Carnage is offline
 
Join Date: Jan 2005
Location: uk
Posts: 760
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

change $status1 to <vb:var status1> in the template. You'll also need to pre-register them to the navbar.
Reply With Quote
  #5  
Old 04-22-2010, 03:48 PM
HolyKiller HolyKiller is offline
 
Join Date: Dec 2006
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 04-23-2010, 11:05 PM
NickyDee NickyDee is offline
 
Join Date: Aug 2008
Posts: 53
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The font tag has been deprecated since 1996. Use CSS to achieve the colour effect instead.
Reply With Quote
  #7  
Old 04-24-2010, 02:40 PM
HolyKiller HolyKiller is offline
 
Join Date: Dec 2006
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 04-24-2010, 05:48 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 04-25-2010, 10:01 PM
HolyKiller HolyKiller is offline
 
Join Date: Dec 2006
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

I'll send some Tequilla shots to California ^^
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:48 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04175 seconds
  • Memory Usage 2,241KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete