Back to vBulletin 4.x Template Modifications

stock market info
Mod Version: 1.00, by gsnindia

vB Version: 4.x.x Rating: (0 vote - 0 average) Installs: 2
Released: 21 Feb 2014 Last Update: Never Downloads: 0
Not Supported Template Edits Code Changes Re-usable Code Translations External Content  

I haven't found any stock market info for vb 4 yet that provide information for any stock market stock or exchange

I have created my own , sharing with you all

How To Install
Step.1:
Please take backup of forum.php before performing this task >> go to forum.php in the last page after
Code:
else
{
	$show['wgo_members']= false;
}
Put this code : You may change the stock array as per your requirement , we use the stock code from Google finance ($Arraysymbol = array("NSE:NIFTY", "NSE:CNXMIDCAP", "NSE:CNX500","NSE:CNX100")

Code:
$Arraysymbol = array("NSE:NIFTY", "NSE:CNXMIDCAP", "NSE:CNX500","NSE:CNX100");
//Obtain Quote Info - This collects the Microsoft Stock Info
 ($hook = vBulletinHook::fetch_hook('prodforums_sensex_bit')) ? eval($hook) : false;
foreach ($Arraysymbol as $i => $value) {
 $quote = file_get_contents('http://www.google.com/finance/info?infotype=infoquoteall&q='. $Arraysymbol[$i]);
  //Remove CR's from ouput - make it one line
  $json = str_replace("\n", "", $quote);
  //Remove //, [ and ] to build qualified string  
  $data = substr($json, 4, strlen($json) -5);
    //decode JSON data
  $json_output = json_decode($data, true);
  //Un-remark print_r to see all array keys
  //print_r($json_output);
       $templater = vB_Template::create('stock_information_bit');
		$templater->register('name', $json_output['name']);
		$templater->register('date', $json_output['lt']);
		$templater->register('live', $json_output['l']);
		$templater->register('change', $json_output['c']);
		$templater->register('changep', $json_output['cp']);
		$templater->register('open', $json_output['op']);
		$templater->register('high', $json_output['hi']);
		$templater->register('low', $json_output['lo']);
		$templater->register('hi52', $json_output['hi52']);
		$templater->register('lo52', $json_output['lo52']);
		$resultsbits .= $templater->render();
   }
// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTTA HERE... ###
($hook = vBulletinHook::fetch_hook('forumhome_complete')) ? eval($hook) : false;
$navbits = construct_navbits($navbits);
$navbar = render_navbar_template($navbits);
$templater = vB_Template::create('FORUMHOME');
	$templater->register_page_templates();
	$templater->register('activemembers', $activemembers);
	$templater->register('activeusers', $activeusers);
	$templater->register('ad_location', $ad_location);
	$templater->register('birthdays', $birthdays);
	$templater->register('forumbits', $forumbits);
	$templater->register('resultsbits', $resultsbits);
	$templater->register('navbar', $navbar);
	$templater->register('newuserinfo', $newuserinfo);
	$templater->register('numberguest', $numberguest);
	$templater->register('numbermembers', $numbermembers);
	$templater->register('numberregistered', $numberregistered);
	$templater->register('recorddate', $recorddate);
	$templater->register('recordtime', $recordtime);
	$templater->register('recordusers', $recordusers);
	$templater->register('template_hook', $template_hook);
	$templater->register('today', $today);
	$templater->register('totalonline', $totalonline);
	$templater->register('totalposts', $totalposts);
	$templater->register('totalthreads', $totalthreads);
	$templater->register('upcomingevents', $upcomingevents);
	$templater->register('sidebar', $sidebar);
	$templater->register('close_sidebar', $close_sidebar);
	$templater->register('sidebar_class', $sidebar_class);
	$templater->register('wgo_members',$wgo_members);
	$templater->register('wgo_members_list',$wgo_members_list);
print_output($templater->render());
Step 2
Create Template with name "stock_information_bit" paste the following code

Code:
<vb:if condition="$change > 0">
<td bgcolor=green>
</vb:if>
<vb:if condition="$change < 0">
<td bgcolor=red>
</vb:if>			<div class="tMrktDtl">
			<div class="boxDtl" >
<div style="color:#FFFFFF"><strong>{vb:raw date}</strong></div>
			<div style="color:#FFFFFF"><strong>{vb:raw name}</strong></div>
			<div class="FL">
			<p style="color:#FFFFFF"> <span></span> <span ><strong>{vb:raw live}</strong></span> <span class="gn_13">{vb:raw change}({vb:raw changep}%)</span> </p>
			</div>
			</div>
</td>
step 3
Open the forumhome tempate

Just after
Code:
	{vb:raw header}
	{vb:raw navbar}

add the following

Code:
  <table   width="100%">
<div>
<tr>
<td><div><span font">MARKETS</span><br>
			<span >TODAY</span><br>
			<span ><script type="text/javascript">
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
document.write(day + "/" + month + "/" + year);
</script></span>
		</div>
</td>
                  {vb:raw resultsbits}
</tr>
</div>
</table>
and your are done

check the result in http://www.gsnindia.com

when the market is down it shows in red , when market is Up it shows in green

You are done

Check The Images

Download

No files for download.

Similar Mods

Add-On Releases vbadvanced stock market vBulletin 3.6 Add-ons

vblts.ru supports vBulletin®, 2022-2024