Make Links Point to Items


If you've been clicking the links in the RSS items that appear in your reader, you know that sometimes the link takes you not to the full item's text, but to a page full of items, and you have to search for the desired item by title.

That's not good RSS. The best way to host the full text of RSS items on your Web site is to set aside one page for each item:

    <html>     <head>      <title>       Steve's news      </title>     </head>     <body>           <h1>Steve's News</h1>      <h2>It's Snowing.</h2>      It's snowing again.      <br>      Will it never stop?      <br>        People are trying to drive through this mess, and nothing         doing.        <br>        Oh well, time to shovel again.     </body>    </html> 


You can, however, group the full text of several RSS items into a single Web page if you provide a link to the specific location of an item's text in that page. You can do that with the HTML <a> element.

Here's how it works. You set the location of a link target with the <a> element, setting the name attribute to the name of the target.

    <html>     <head>      <title>       Steve's news      </title>     </head>     <body>      <h1>Steve's News</h1>            <a name="welcome">      <h2>Welcome to Steve's news</h2>      You'll find all kinds of news from Steve here.      <br>      Stay tuned.            <a name="snow">      <h2>It's Snowing.</h2>      It's snowing again.      <br>      Will it never stop?      <br>      People are trying to drive through this mess, and nothing      doing.      <br>      Oh well, time to shovel again.     </body>    </html> 


Now you can make the browser jump to a specific link target by including the target's name in the link after a pound (#) sign.

    <?xml version="1.0" encoding="ISO-8859-1"?>    <rss version="2.0">     <channel>            .            .            .        <item>         <title>Steve shovels the snow, which might now be turning to         rain, and who knows what's next.</title>         <description><![CDATA[It snowed once again. Time         to shovel!]]></description>         <pubDate>Thu, 08 Dec 2005 08:39:51 -0500</pubDate>         <link>http://www.rssmaniac.com/steve/news.html#snow</link>        </item>        <textinput>          <title>Do a Search</title>          <description>What do you want to find?</description>          <name>search</name>          <link>http://www.rssmaniac.com/find.cgi</link>        </textinput>     </channel>    </rss> 


The link http://www.rssmaniac.com/steve/news.html#snow points to the "snow" link target in the page http://www.rssmaniac.com/steve/news.html, so when the user clicks that link, his or her browser navigates to that location in the Web page. Thus the reader doesn't have to navigate through the whole page to find the correct article. Very nice.

Tip

Another good idea is to use permalinks, which permanently point to the location they're supposed to. Too many URLs on the Web are broken, or become broken shortly after being published.




Secrets of RSS
Secrets of RSS
ISBN: 0321426223
EAN: 2147483647
Year: 2004
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net