News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Advertising Your Board's RSS Feed...

Started by Oldiesmann, November 22, 2004, 11:56:25 AM

Previous topic - Next topic

Oldiesmann

One of the great features in SMF is its XML and RSS functions. With one simple option enabled, SMF is capable of generating RSS and XML feeds for your board's news, member profiles and latest topics. Mozilla Firefox displays a special icon in the status bar when it detects an RSS feed on a site and even allows you to add RSS feeds to your bookmarks ("live bookmarks" - creates a folder in your bookmarks list for each feed and then puts the links generated by that feed in that folder, allowing you to easily access them). Anyway, Kelnage indicated that it would be nice to see SMF automatically "advertise" the fact that you've got RSS feeds on your board. Here's how you do that:

First, make sure you've got it enabled (Admin -> Edit Features and Options -> Enable XML/RSS News).

Next:

Themes/yourtheme/index.template.php

Find
// Show all the relative links, such as help, search, contents, and the like.
echo '
<link rel="help" href="', $scripturl, '?action=help" target="_blank" />
<link rel="search" href="' . $scripturl . '?action=search" />
<link rel="contents" href="', $scripturl, '" />';


Add after
// If RSS/XML news is enabled, indicate that an RSS feed is available
if (!empty($modSettings['xmlnews_enable']))
echo '
<link rel="alternate" type="application/rss+xml" title="RSS" href="', $scripturl, '?type=rss;action=.xml;limit=20" />';


You can change that to your liking. Check out Sources/News.php for more info on all the XML feeds available. Once again, thanks to Kelnage for mentioning how to "advertise" the feed.
Michael Eshom
Christian Metal Fans

jcompton

Is there more detail available on turning these feeds on? I do have that "one simple option enabled" but Yahoo's RSS module doesn't recognize my latest-post URL as a valid feed so presumably there's something a bit more to it than that.

Kelnage

Your latest post isn't an RSS feed.

To get the RSS feed manually, the link is:

http://www.yourserver.com/foldername/index.php?type=rss;action=.xml;limit=20 [nofollow]

That gets 20 messages. To get more or less, just change the last number.

jcompton

Ah, thanks. Looks like half the time Yahoo claims there's no new posts for the past 3 days, but I have no way of knowing whose fault that is offhand...

jcompton

Actually, no, I still seem to be missing something here.

http://forums.pocketplane.net/index.php?type=rss;action=.xml;limit=6

This URL pulled up 5 items into My Yahoo, but those items are not updating. They're just getting older and older...

Oldiesmann

Works fine in Firefox. It's displaying links to the 6 most recent posts. I don't know how Yahoo handles this though.
Michael Eshom
Christian Metal Fans

Oldiesmann

Everything Yahoo is showing is an hour old. I'm guessing it only gets headlines every hour or so.
Michael Eshom
Christian Metal Fans

Lum-chan

Thanks for the tip Oldiesman, I finally got it working  ;D
Lum-chan


[Unknown]

I'm pretty sure the content type should be application/rss+xml.

-[Unknown]

Oldiesmann

That's just what Kelnage had. I'll change it though.
Michael Eshom
Christian Metal Fans

Kelnage

Cheers [Unknown], I wasn't certain, but RSS worked with Firefox, and seeing as RSS readers are supposed to be extremely strict, I didn't think there was a problem.

Oldiesmann

You can add multiple links too...

For example:

echo '
  <link rel="alternate" type="application/rss+xml" title="20 Most Recent Topics" href="', $scripturl, '?type=rss;action=.xml;limit=20" />
  <link rel="alternate" type="application/rss+xml" title="News" href="', $scripturl, '?type=rss;action=.xml;sa=news" />';


Then when you click on the little icon in Firefox, you will be given an option of which feed you want to subscribe to. :)
Michael Eshom
Christian Metal Fans

nosleep

QuoteActually, no, I still seem to be missing something here.

http://forums.pocketplane.net/index.php?type=rss;action=.xml;limit=6

This URL pulled up 5 items into My Yahoo, but those items are not updating. They're just getting older and older...


and what would the link be for example a section like this: Video and Photo Room

http://www.yourserver.com/foldername/index.php?type=rss;action=.xml;limit=20

because the quoted link doesn't pull from a specific section of the forum...

[Unknown]

Put ;board=XYZ on the link for a specific board.

-[Unknown]

nosleep

#14
like this?

http://myhomepage.com/portal/forum/index.php?type=rss;action=.xml;limit=20;board=Politics and Sports

because I get this error when calling the feed:

Completed: with problems:
http://myhomepage.com/portal/forum/index.php?type=rss;action=.xml;limit=20;board=Politics and Sports


additionally: must I be logged in to call the feed, as that section is only available to loged in users.

can I possibly add my login and password to the string?

[Unknown]

I'm afraid you have to look at the board's number.  For example, Tips and Tricks is 72 - you cna tell from the URL.

-[Unknown]

nosleep

#16
thank you, mine was a silly question on afterthought, should have known that from phpbb, on which it is the same.


but it won't pull the news. The board no. looks like this (on default template 1.0 preview):

....index.php/board,5.0.html

so do I have to call only the 5, or the 5.0, ot 5.0.html ?

have tried all three, but none will pull the news.

again, this section is only for logged in users.......

[Unknown]


nosleep

tried that now as well, it won't pull the feed.... no clue why.

tried axatly you string above, only changed to my url.

Atari

I finally got a look at this but still not sure about something. Do I really need to edit? I tried the direct link and added to my bookmarks and it seems to work. I tried to look for that stuff in my template but its not there so I didn't add the extra code. ( I'm using helios template). Does that code give you some more control on what shows?

There are 10 kinds of people in this World.
Those who understand Binary and those who don't

Advertisement: