View Single Post
  #1  
Old 04-14-2009, 04:24 AM
MickDoneDee MickDoneDee is offline
 
Join Date: Mar 2003
Location: Sydney
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to add a widget to a popup window

I'll preface this by saying I'm not a coder but, through trial and error, I managed to get this to work.

The shape of most widgets make them difficult to place neatly anywhere on a vbulletin forum. The only alternative is to make them popup in a new window which has the same dimensions as the popup.

The java-based widget I wanted to add to my cricket forum can be found at Cricinfo. Go to my World A Team cricket forum to see a demo. Click the "Live Scores" link on the navbar. The popup window opens first. The widget inside the window is a little slower to load. You must have java enabled in your browser.

What you will need to edit or create:

1. Create a standard phrase. I created Varname: live_scores; Text: Live Scores. So, the phrase variable in the navbar template is $vbphrase[live_scores].

2. Create a plugin. Plugin Title: live_scores; Hook Location: misc_start; Plugin PHP Code:

Code:
// ############################### start live scores ###############################
if ($_REQUEST['do'] == 'livescores')
{
	eval('print_output("' . fetch_template('live_scores') . '");');
}
3. Create a template. I created a template called live_scores and copied contents of shell_blank template into it. I also replaced $header; $navbar; $html; $footer from between the <body> tags with the widget javascript. I also replaced $pagetitle between the <title> tags with $vbphrase[live_scores].

4. Edit navbar template. I used the code for the Buddy List popup as a template for the widget popup and replaced references to buddylist with livescores. I also ammended the Width and Height values to match the widget W&H values. Buddy List popup code looks like this:
Code:
				<td class="vbmenu_control"><a href="#" onclick="window.open('misc.php?$session[sessionurl]do=buddylist&amp;focus=1','buddylist','statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=250,height=300'); return false;">$vbphrase[open_buddy_list]</a></td>
I copied and modified it to look like:
Code:
<!-- Live Scores -->
				<td class="vbmenu_control"><a href="#" onclick="window.open('misc.php?$session[sessionurl]do=livescores&amp;focus=1','livescores','statusbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,width=400,height=270'); return false;">$vbphrase[live_scores]</a></td>
<!-- End Live Scores -->
Make sure you place the new popup code inside this conditional: <if condition="$show['popups']">. An explanation of why can be found at vBulletin.com. The conditional is already in the navbar template. Search the template for it and place the code below it.

5. Edit misc.php. Add your template to get it pre-cached. I added the code red and bolded:
Code:
// pre-cache templates used by specific actions

	'showsmilies' => array(
		'help_smilies',
		'help_smilies_smilie',
		'help_smilies_category',
	),
	'livescores' => array(
		'live_scores',
	)
);
Please add your suggestions if anything can be improved.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02085 seconds
  • Memory Usage 1,781KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete