anchors in rss feed

You have a suggestion for a future version of phpMyFAQ? Then post it here!

Moderator: Thorsten

Post Reply
tc
Posts: 1
Joined: Mon Oct 17, 2005 1:58 am

anchors in rss feed

Post by tc »

The rss feed provides the link for the *page* only. In a list of five articles, all link to the main page. It would be dramatically better if the individual links led directly to the particular story.
Thorsten
Posts: 15747
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

th RSS feeds provide links to the article in version 1.5.x

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
tc9
Posts: 3
Joined: Sat Oct 22, 2005 10:29 pm

rss feed

Post by tc9 »

Really? I am currently uising 1.5.3. The rss feed sends out exactly the same link for all items in the list of news stories.

Here is the code (feed/news/rss.php, line 54), I believe:

Code: Select all

$rss .= "\t\t<link>http".(isset($_SERVER['HTTPS']) ? 's' : '')."://".$_SERVER["HTTP_HOST"].str_replace ("/feed/news/rss.php", "", $_SERVER["PHP_SELF"])."</link>\n";
The link does not seem to include any identifier that is specific to a particular news story.

But, if it is changed to this:

Code: Select all

$rss .= "\t\t<link>http".(isset($_SERVER['HTTPS']) ? 's' : '')."://".$_SERVER["HTTP_HOST"].str_replace ("/feed/news/rss.php", "", $_SERVER["PHP_SELF"])."/index.php#".$row->id."</link>\n";
and a corresponding change is made to add the anchor to the news script, it works fine.

For example, test this link (with the anchor): http://westport.dumais.us/staplesfaq/index.php#43

Thanks!,

CD
Thorsten
Posts: 15747
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

you're right... I'll add this!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
tc9
Posts: 3
Joined: Sat Oct 22, 2005 10:29 pm

Modified Version of News RSS Feed

Post by tc9 »

Thorsten,

Instead of using page anchors, I have modified main.php, function.php, and rss.php to display a single news article on the page. What do you think?

In inc/functions.php find

Code: Select all

function generateNews()
{
	global $db, $PMF_LANG, $PMF_CONF;
	$counter = 0;
	$result = $db->query("SELECT datum, header, artikel, link, linktitel, target FROM ".SQLPREFIX."faqnews ORDER BY datum desc");
	$output = "";
and change it to

Code: Select all

function generateNews($lang,$id)
{
	global $db, $PMF_LANG, $PMF_CONF;
	$counter = 0;

	$id==0 ? $result = $db->query("SELECT datum, header, artikel, link, linktitel, target FROM ".SQLPREFIX."faqnews ORDER BY datum desc") : $result = $db->query("SELECT id, datum, header, artikel, link, linktitel, target FROM ".SQLPREFIX."faqnews WHERE id=".$id."");

	$output = "";
In main.php find

Code: Select all

if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

$tpl->processTemplate ('writeContent', array(
                       'writeNewsHeader' => $PMF_CONF['title'].$PMF_LANG['msgNews'],
                       'writeNews' => generateNews($LANGCODE),
                       'writeNumberOfArticles' =>
and change it to

Code: Select all

if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

if (!isset($_GET['id'])) {
	$id=0;
}

$tpl->processTemplate ('writeContent', array(
                       'writeNewsHeader' => $PMF_CONF['title'].$PMF_LANG['msgNews'],
                       'writeNews' => generateNews($LANGCODE, $id),
                       'writeNumberOfArticles' =>
In feed/news/rss.php find

Code: Select all

$rss .= "\t<item>\n";
        $rss .= "\t\t<title><![CDATA[".$row->header."]]></title>\n";
        $rss .= "\t\t<description><![CDATA[".stripslashes($row->artikel)."]]></description>\n";
        $rss .= "\t\t<link>http".(isset($_SERVER['HTTPS']) ? 's' : '')."://".$_SERVER["HTTP_HOST"].str_replace ("/feed/news/rss.php", "", $_SERVER["PHP_SELF"])."</link>\n";
        $rss .= "\t\t<pubDate>".makeRFC822Date($row->datum)."</pubDate>\n";
        $rss .= "\t</item>\n";
and change it to

Code: Select all

$rss .= "\t<item>\n";
        $rss .= "\t\t<title><![CDATA[".$row->header."]]></title>\n";
        $rss .= "\t\t<description><![CDATA[".stripslashes($row->artikel)."]]></description>\n";
        $rss .= "\t\t<link>http".(isset($_SERVER['HTTPS']) ? 's' : '')."://".$_SERVER["HTTP_HOST"].str_replace ("/feed/news/rss.php", "", $_SERVER["PHP_SELF"])."/index.php?id=".$row->id."</link>\n";
        $rss .= "\t\t<pubDate>".makeRFC822Date($row->datum)."</pubDate>\n";
        $rss .= "\t</item>\n";
Thorsten
Posts: 15747
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

we're already implemented a new news class for phpMyFAQ 1.6. Thanks for your proposal...

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply