how to add IRC to your vBulletin forum/CMS
goal: create a tab that features the webclient of quakenet or freenode to choose from
first, we need to add some tab to the navigation bar:
1. Create a plugin in the Admin Control Panel under (Plugins & Products) > Add New Plugin:
2. set hook location to "process_templates_complete"
3. set Title to "IRC TAB for navbar" (wont get displayed)
4. add the following php code:
1 2 3 4 5 6 7 8 9 10 11 12 13 | $tabselected = ''; $tablinks = ''; if (THIS_SCRIPT == 'irc') { $vbulletin->options['selectednavtab']='irc'; $tabselected = ' class="selected"'; $tablinks = ' <ul class="floatcontainer"> <li>Quakenet IRC</li> <li>FreeNode IRC</li> </ul> '; } $template_hook['navtab_end'] .= '<li'.$tabselected.'>Chat'.$tablinks.'</li>' ; |
5. after that, create a new file in the web folder (/) named "irc.php":
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <?php // #################### DEFINE IMPORTANT CONSTANTS ####################### define('THIS_SCRIPT', 'irc'); define('CSRF_PROTECTION', true); // change this depending on your filename // ################### PRE-CACHE TEMPLATES AND DATA ###################### // get special phrase groups $phrasegroups = array(); $specialtemplates = array(); $globaltemplates = array('irc'); $actiontemplates = array(); // if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line // chdir ('/path/to/your/forums'); require_once('./global.php'); $navbits = construct_navbits(array('' => 'irc')); $navbar = render_navbar_template($navbits); $pagetitle = 'IRC Chat'; $templater = vB_Template::create('irc'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('pagetitle', $pagetitle); $network='quakenet'; if(isset($_GET['network'])) $network = addslashes($_GET['network']); $templater->register('irc_network', $network); if($vbulletin->userinfo['userid'] == 0) // guest print_no_permission(); $templater->register('username', $vbulletin->userinfo['username']); print_output($templater->render()); ?> |
6. add the template required for rendering the new page:
in the admin control panel > Styles & Templates > Style Manager > (select "add new template" from your style)
style title: irc
template:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | {vb:stylevar htmldoctype} <html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}"> <head> {vb:raw headinclude} {vb:raw headinclude_bottom} {vb:raw header_scripts} </head> <script language="javascript"> <!-- window.onbeforeunload = function(){ return 'When you close this site the chat will also stop.';} --> </script> <body> {vb:raw header} {vb:raw navbar} <vb:if condition="$irc_network == 'quakenet'"> <iframe src="http://webchat.quakenet.org/?nick={vb:raw username}&channels=rigsofrods&uio=OT10cnVlJjExPTUx91" width="100%" height="400"></iframe> </vb:if> <vb:if condition="$irc_network == 'freenode'"> <iframe src="http://webchat.freenode.net?nick={vb:raw username}&channels=rigsofrods" width="100%" height="400"></iframe> </vb:if> {vb:raw footer} </body> </html> |
thats it, should work well
(you should replace "rigsofrods" with your own channel
(used this tutorial: http://www.vbulletin.org/forum/showthread.php?t=226914)