An Introduction to WebSphere Portal content publishing channels By Gregory Melahn Software Engineer, IBM Corp. May 2003 Abstract WebSphere Portal content publishing (WPCP) allows you to import news stories and other syndicated content in the form of channels. This paper provides an overview of this support and shows examples of how you can generate and preview news lists from channels. What are channels? Syndicated content is typically described using XML and organized into collections called channels. For example, one can find a channel about IBM and another channel about Celebrity News. A channel is described in a single file. One popular XML format for describing syndicated content is called RSS.
Here is an example of a channel. I There are different versions of RSS. WPCP supports the 0.91 and 0.92 versions. The version of a channel can be found in the <rss version> tag.
Where can I find channels? Syndicated content is made available to Web sites by content aggregators. Aggregators take content from a variety of sources and make it available in formats like RSS. One easy way to find sources of channels is to search the Web for the term RSS. You may be surprised what you find. For example, you will find Web log providers sometimes externalize their blogs as channels. Some providers I have found include. Meerkat Moreover My.UserLand Network 54 NewsIsFree Syndic8 Xmltree 10.am Once you find a channel provider, check to make sure you understand and can comply with the service terms before using their content on your web site. Then, note the URL s of the channels you are interested in. For example, moreover.com provides a URL for IBM news, http://p.moreover.com/cgi-local/page?c=ibm%20news&o=rss
Importing channels into WPCP The first step of importing a channel is to define the channel in WPCP. This is done on the WPCP Admin page. Click the Channels node on the Administration page.
Then click the Add channel button.
If you want to preview the contents of the channel, click the Preview button and you will see the links provided by this channel.
If you like what you see, click the Create button and the channel will be added to WPCP s channel list.
Since the contents of the channel change often, you may want to schedule automatic updates. To schedule automatic updates, click the clock icon, enter the desired frequency, and click the Save button.
When you add the channel, the items in the channel are added to the WPCP content list. To see these items, go back to the Content tab and click on the IBMNews folder.. What can I do with channels? Think of channels as raw material for your content. There are a number of things you can do with this raw material to turn it into content that is usable on your Web site. First, it is useful to write a preview template that allows you to view the news story to see if is an appropriate item for your site. Here is an example of such a simple preview template. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <title>channel Item</title> <jsp:usebean id="getresource" class="com.ibm.wcm.getgenericresource" type="com.ibm.wcm.getgenericresource"><% getresource.getresource(request); %></jsp:usebean> <jsp:usebean id="resobj" scope="request" type="com.ibm.wcm.resources.rsschannelitem"/> <body bgcolor="#cfcfcf"> <CENTER> <% { Object propvalue = null;
propvalue = resobj.getchanneltitle(); if( propvalue==null ) propvalue = new String(" "); %> <H1><I><U>Breaking News from <%= propvalue.tostring() %></I></U></H1> <% } %> <br> <% { Object propvalue = null; propvalue = resobj.gettitle(); if( propvalue==null ) propvalue = new String(" "); %> <H2><%= propvalue.tostring() %> <% } %> </H2> <% { Object propvalue = null; propvalue = resobj.getdescription(); if( propvalue==null ) propvalue = new String(" "); %> <P><%= propvalue.tostring() %> <% } %> <% { Object propvalue = null; propvalue = resobj.getlink(); if( propvalue==null ) propvalue = new String(" "); %> <br> <A HREF="<%= propvalue.tostring() %>"><IMG SRC="/wps/WPCPfr/news.gif"></A> <% } %> </CENTER> </body> </html>
Then associate your template with the WPCP folder in which you stored the contents of the channel, as in this example.
Now you can preview the contents of the channel by just clicking on the link, then clicking on the News button.
Clicking on the News button shows the actual story.
If the contents of this folder are news stories that you want to appear on your site, you can create a WPCP generation template that writes the link to an html page. Here is an example of such a template. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>News Summary</TITLE> <META http-equiv="content-type" content="text/html; charset=iso-8859-1"> <META http-equiv="content-style-type" content="text/css"> </HEAD> <BODY> <% // The resource can be retrieved using this generic class %> <jsp:usebean class="com.ibm.wcm.getgenericresourcelist" id="getresourcelist" type="com.ibm.wcm.getgenericresourcelist"><% getresourcelist.setrequest(request); %></jsp:usebean> <% java.util.enumeration enumobjs = getresourcelist.getresourcelist(); String path=""; if( enumobjs==null ) { out.println("<br>getresourcelist.getresourcelist() returned null object"); return; } java.util.enumeration enumobjs2 = getresourcelist.getresourcelist(); if( enumobjs2==null ) { out.println("<br>getresourcelist.getresourcelist() returned null object"); return; } else { com.ibm.wcm.resources.rsschannelitem anewsstory = (com.ibm.wcm.resources.rsschannelitem)enumobjs2.nextelement(); path = (String)aNewsStory.get("PATH"); if (path.equals("/")) { path="root"; } path = path.replace('/',' '); } %> <H1>The Latest News</H1> <H2>Topic:<%=path%></H2> <TABLE width="100%" align="middle" cellpadding="0" cellspacing="0" border="0"> <TBODY> <!--Spacer row--> <TR> <TD colspan="3" height="8" width="100%"></td> </TR>
<!--Nav bar: bottom section--> <TD width="50%" align="center"> <TABLE width="400" align="center" cellpadding="0" cellspacing="0" > <!--How to show a news story list--> <TR> <TD align="center" valign="top"> <% try { %> <TABLE border="0" cellpadding="2" cellspacing="0" width="500"> <TBODY> <TR> <TD align="left" valign="top"><font color="3366cc"><b>news Story</B></FONT></TD> <TD align="left" valign="top"> </TD> </TR> <TR> <TD align="left" colspan="4" height="1" valign="middle" width="400"><img alt="blue line" border="0" height="1" src="../../../theme/bluepixel.gif" width="396"><br></td> </TR> <% while( enumobjs.hasmoreelements() ) { com.ibm.wcm.resources.rsschannelitem news = (com.ibm.wcm.resources.rsschannelitem)enumobjs.nextelement(); %> <TR> <TD align="left" valign="top"><u><a href="<%= news.getlink() %>"><%= news.gettitle() %></U> </A></TD> <TD align="left" valign="top"> </TD> </TR> <% } %> <TR> <TD align="left" colspan="4" height="1" valign="middle" width="400"><img alt="blue line" border="0" height="1" src="../../../theme/bluepixel.gif" width="396"><br></td> </TR> </TBODY> </TABLE><% } catch( Exception exc ) { out.println( exc ); exc.printstacktrace(); } %> </TD> </TR> </TABLE>
</TD> <TD width="25%"> </TD> </TR> </TBODY> </TABLE> </BODY> </HTML>
Associate this template as a summary generation template, as shown here.
Then click the Generate button to generate an html page.
Notice the page has now been generated in WPCP. Click on the page to see the contents as they will appear on your web site. Note that the format of this page is under your control if you want to change it, just modify the summary template and regenerate the page.
Trademarks Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. ActiveX, Microsoft, Windows, Windows NT(R), and the Windows logo are trademarks or registered trademarks of Microsoft Corporation in the United States, or other countries, or both. UNIX is a registered trademark of The Open Group. Other company, product, and service names, which may be denoted by a double asterisk (**), may be trademarks or service marks of others. Notices The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION AND ANY ASSOCIATED CODE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OR CONDITIONS OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you. This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice. Copyright International Business Machines Corporation 2003. All rights reserved. US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.