News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Can't put in the correct board title in my RSS-feed

Started by torkil, June 03, 2005, 03:59:25 AM

Previous topic - Next topic

torkil

I have made modifications to my theme so that the template is always showing an RSS link for the forum you are currently in. I run a martial arts forum, so if a user wants an RSS to the whole forum he can get that from the frontpage, if he wants an RSS for one of the subforums he can get that from the subforums page.

See it in action at http://www.kampforum.com/forum/

The RSS-feeds are both added as a link-tag in the page header and as a regular html-tag in the breadcrumb area.

I do have a problem however, that I'd appreciate any tips on: The RSS feed will always show up in my RSS reader as "Kampforum.com". Meaning: When the RSS reader is fetching the RSS, the title of the feed is screwed up. I want it to say "Kampforum.com - Subforum name here". I guess I need to correct my code for how to fetch the forum title... Suggestions anyone?

Here is my code that i place in index.template.php, right before the stylesheet is added, inside the head-area:

// Print RSS if it is turned on on
if (!empty($modSettings['xmlnews_enable'])) {
if ($_REQUEST['board']) {
$spotnumber = count($context['linktree'])-1;
$rss_title = $context['linktree'][$spotnumber]['name'];
echo '
<link rel="alternate" type="application/xml" title="Kampforum RSS: '.$rss_title.' - 20 latest" href="http://www.kampforum.com/forum/index.php?action=.xml;type=rss;sa=recent;board='.$context['current_board'].';limit=20" /> ';
} elseif ($_REQUEST['topic']) {
$spotnumber = count($context['linktree'])-2;
$rss_title = $context['linktree'][$spotnumber]['name'];
echo '
<link rel="alternate" type="application/xml" title="Kampforum RSS: '.$rss_title.' - 20 latest" href="http://www.kampforum.com/forum/index.php?action=.xml;type=rss;sa=recent;board='.$context['current_board'].';limit=20" /> ';
} else {
echo '
<link rel="alternate" type="application/xml" title="Kampforum RSS: 20 latest" href="http://www.kampforum.com/forum/index.php?action=.xml;type=rss;sa=recent;limit=20" /> ';
}
}


This is the code I use for adding the RSS-link at the end of the breadcrumbs. Put this code at the end of function theme_linktree() inside index.template.php :

// Print RSS link if it is on
if (!empty($modSettings['xmlnews_enable'])) {
echo '<div style="float: left; background-color: #f90; font-size: 9px; border: 1px solid #fc0; padding: 0px 2px;; line-height: 1em;">';
if ($_REQUEST['board']) {
$spotnumber = count($context['linktree'])-1;
$rss_title = $context['linktree'][$spotnumber]['name'];
echo '<a title="Kampforum RSS: '.$rss_title.' - 20 latest" href="http://www.kampforum.com/forum/index.php?action=.xml;type=rss;sa=recent;board='.$context['current_board'].';limit=20" style="font-weight: normal; text-decoration: none; color: #fff;">';
} elseif ($_REQUEST['topic']) {
$spotnumber = count($context['linktree'])-2;
$rss_title = $context['linktree'][$spotnumber]['name'];
echo '<a title="Kampforum RSS: '.$rss_title.' - 20 latest" href="http://www.kampforum.com/forum/index.php?action=.xml;type=rss;sa=recent;board='.$context['current_board'].';limit=20" style="font-weight: normal; text-decoration: none; color: #fff;">';
} else {
echo '<a title="Kampforum RSS: 20 latest" href="http://www.kampforum.com/forum/index.php?action=.xml;type=rss;sa=recent;limit=20" style="font-weight: normal; text-decoration: none; color: #fff;">';
}
echo 'RSS</a>';
echo '</div>';
}


Currently the forums title isn't being put in there correctly, but I'm asking around on the general questions forum to fix that.

[Unknown]

You need to change News.php for that.  The <title> attribute.

-[Unknown]


Advertisement: