pftq.com
Blabberbox » Embedding Stock Charts on SMF ForumsShare on Twitter

Embedding Stock Charts on SMF Forums

December 28th, 2009 | Posted by pftq in Blabberbox | #

So I was looking for a way to embed stock charts into posts for SMF Forums, probably via bbcode or tags. I checked Google all morning and couldn’t find it though. If it exists, please redirect me because I’m sure it’ll be much better than my makeshift solution. :P

In the meantime, I modified my forums to use a tag called [schart]. When someone types [schart]SYMBOL[/schart], it shows the stock chart in its place.
The editing isn’t complicated, but you need another site to embed from. Right now, I’m using Wikinvest, but it’s a bit slow and heavy (it’s interactive and flash, fancy stuff). If anyone knows a good, fast-loading static one, it’d be nice to know. :D

For the code, go to Sources/Subs.php and find “function parse_bbc”.
At the end of the $codes array, or after:

array(
‘tag’ => ‘white’,
‘before’ => ‘<span style=”color: white;”>’,
‘after’ => ‘</span>’,
),

Insert:

//Moddie Stock Charts
array(
‘tag’ => ’schart’,
‘type’ => ‘unparsed_content’,
‘content’ => ‘<script src=”
http://charts.wikinvest.com/wikinvest/wikichart/javascript/scripts.php” type=”text/javascript”></script><div id=”wikichartContainer_645B01FB-’.($srand=rand(1000,9999).’-’.rand(1000,9999)).’-$1-D729C4917DE2″><div style=”width: 390px; text-align: center; vertical-align: center; margin-top: 22px;”><a href=”http://get.adobe.com/flashplayer/”><img src=”http://cdn.wikinvest.com/wikinvest/images/adobe_flash_logo.gif” alt=”Flash” style=”border-width: 0px;”/><br/>Flash Player 9 or higher is required to view the chart<br/><strong>Click here to download Flash Player now</strong></a></div></div><script type=”text/javascript”>if (typeof(embedWikichart) != “undefined”) {embedWikichart(”http://charts.wikinvest.com/WikiChartMini.swf”,”wikichartContainer_645B01FB-’.$srand.’-$1-D729C4917DE2″,”390″,”245″,{”ticker”:”$1″,”liveQuote”:”true”,”showAnnotations”:”false”,”rollingDate”:”6 months”});}</script>’
),

Usually the chart ID (container) is set so that you can save changes to the chart, but I’m really just looking for the chart display alone. The ID is randomized so that you don’t have to create a new chart at Wikinvest each time. The problem might be that you accidentally use the ID of an existing chart, but the chance of that should be relatively small (and even so, you’re not making changes to the saved chart).

Of course, if anyone knows a chart that doesn’t need an ID or settings to be saved, that’d be even better. I’m still looking for one right now, but this is what I’m using in the mean time. :)

Update 20100112:
Found a few other sources for charts. This one loads quickly as an image: http://www.profitspi.com/

Just replace the content code with:

‘content’ => ‘<img src=”http://www.profitspi.com/stock-chart-str.aspx?id=$1&amp;ca=24062939″ alt=”$1″ />’

1043 unique view(s)

Leave a Comment

Name: (Have an account? Login or Register)
Email: (Won't be published)
Website: (Optional)
Comment:
Enter the code from image: