Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft SharePoint 2010 Business Application Blueprints

You're reading from   Microsoft SharePoint 2010 Business Application Blueprints Master SharePoint application development by building exciting SharePoint business solutions with this book and ebook.

Arrow left icon
Product type Paperback
Published in Jun 2012
Publisher Packt
ISBN-13 9781849683609
Length 282 pages
Edition 1st Edition
Arrow right icon
Toc

Table of Contents (15) Chapters Close

Microsoft SharePoint 2010 Business Application Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Building an Effective Intranet 2. Building an Out of Office Delegation Solution FREE CHAPTER 3. Building an Enterprise Content Management Solution 4. Building an Engaging Community Site 5. Building a Site Request and Provisioning System 6. Building a Project Site Template 7. Building a Project Management Main Site 8. Building a Task Rollup Solution 9. Building a Site Directory with SharePoint Search

Building a Stock Ticker Web Part


For publicly traded companies it is also desirable to display the current stock quote information. Like the Weather Web Part previously configured, there are many publicly available services that can provide this information. For this example, we will query a REST based service provided by Yahoo having the following address:

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol in ("MSFT")&env=store://datatables.org/alltableswithkeys

Approach

The stock quote information can be shown in a number of different ways. In cases where the information needs to be on every page, it should be added to a container on the Master Page with the s4-notdlg style reference previously included in the Building an Appropriate Use and Incident dialog section. For this example though, we will include it as an XML Web Part configured in a similar way to the Weather Web Part previously reviewed.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-
prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template name="main">
<xsl:variable name="symbol" select="results/quote/Symbol"/>
<xsl:variable name="price"
select="results/quote/LastTradePriceOnly"/>
<xsl:variable name="change"
select="results/quote/Change_PercentChange"/>
<div id="stockInfo" style="font-size:10pt">
<xsl:value-of select="$symbol" />
<xsl:text> $</xsl:text>
<xsl:value-of select="$price" />
<xsl:text> </xsl:text>
<xsl:value-of select="$change" />
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="contains($change,'+')" >
<img
src="http://intranet/Style%20Library/Images/stock_up.png"
border="0" alt="Trending Up"></img>
</xsl:when>
<xsl:otherwise>
<img
src="http://intranet/Style%20Library/Images/stock_down.png"
border="0" alt="Trending Down"></img>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
<xsl:template match="/*">
<xsl:call-template name="main"/>
</xsl:template>
</xsl:stylesheet>

Stock Quote Web Part displayed

A rendered version of the current Stock Ticker Web Part can be displayed in the following screenshot:

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image