Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Tutorial 2 RSS-Feed Error


Go to End


8 Posts   3109 Views

Avatar
zehjot

Community Member, 6 Posts

3 August 2009 at 11:06pm

Dear all,

I have stumbled over the same problem as described in this thread on this forum but the advise given there did not work for me. So basically, having implemented rss functionality following the steps in the tutorial, I ran into the same problem with the following output. I've looked for whitespace creating lines, but could not find any. Your help is much appreciated. Best regards, zehjot.

My ArticleHolder.php looks like this. There are no whitespaces in the file before or after the <? and ?> tags.

<?php
/**
* Defines the ArticleHolder page type
*/
class ArticleHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $icon = "themes/tutorial/images/treeicons/news";
static $allowed_children = array('ArticlePage');
}

class ArticleHolder_Controller extends Page_Controller {

function rss() {
$rss = new RSSFeed($this->Children(), $this->Link(), "The coolest news around");
$rss->outputToBrowser();
}

function init() {
RSSFeed::linkToFeed($this->Link() . "rss");
parent::init();
}
}
?>

#########################Output:

[Warning] Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\silverstripe\mysite\code\ArticleHolder.php:1)
GET /silverstripe/nachrichten/rss

Line 188 in C:\xampp\htdocs\silverstripe\sapphire\api\RSSFeed.php
Source

179 HTTP::register_modification_timestamp($this->lastModified);
180 header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $this->lastModified) . ' GMT');
181 }
182 if(!empty($this->etag)) {
183 HTTP::register_etag($this->etag);
184 }
185
186 $body = $this->feedContent();
187 HTTP::add_cache_headers();
188 header("Content-type: text/xml");
189 echo $body;
190 }
191
192 /**
193 * Return the content of the RSS feed
194 */

Trace

* header(Content-type: text/xml)
Line 188 of RSSFeed.php
* RSSFeed->outputToBrowser()
Line 18 of ArticleHolder.php
* ArticleHolder_Controller->rss(HTTPRequest)
Line 162 of Controller.php
* Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 29 of ModelAsController.php
* ModelAsController->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/nachrichten/rss)
Line 118 of main.php

Avatar
bummzack

Community Member, 904 Posts

4 August 2009 at 12:30am

Edited: 04/08/2009 12:33am

Have you tried removing the closing ?> entirely? It is not needed in PHP only files. For pure php code it is even considered good practice, to omit the closing tag (as seen at Zend Framework, Drupal, even php.net)

Update: You also have to change Page.php, since your ArticleHolder inherits from it

Avatar
zehjot

Community Member, 6 Posts

4 August 2009 at 1:39am

Hi banal,

thanks for your reply. I've removed the closing tag in both files (ArticleHolder.php and Page.php) with no effect. What do I have to change in the Page.php?

Avatar
bummzack

Community Member, 904 Posts

4 August 2009 at 2:00am

Hm. That's strange. You're sure, there's no special characters whatsoever before the opening tag (<?php) in both ArticleHolder.php and Page.php?
This error message looks like it's coming from Line 1 in ArticleHolder.php

output started at C:\xampp\htdocs\silverstripe\mysite\code\ArticleHolder.php:1

Avatar
zehjot

Community Member, 6 Posts

4 August 2009 at 2:29am

No, nothing like it. Its coded utf-8 however. With Windows (CR/LF) linebreaks.

Avatar
Juanitou

Community Member, 323 Posts

5 August 2009 at 4:27am

Hi zehojt!

Have you tried saving it in UTF-8 without BOM?

Avatar
ezero

Community Member, 7 Posts

21 August 2009 at 11:45am

I had a similar problem. I have no idea how i fixed it.

I think it was the cache.. or I cut and pasted a piece of code from (function) which it told me what line number it was on.

In your case its line 1.

ArticleHolder.php:1

You can get away with it by going /rss?isDev=0&flush=1

Avatar
Chip Designs

Community Member, 15 Posts

25 March 2010 at 5:17pm

Hi there,
I had a similar problem with the blog module.
After checking my entire site for white spaces, I finally found the white space that was causing the issue. The page was a custom page I made for the site, in my case it was called HomePage.php found @ mysite/code/HomePage.php. So if you have any custom pages, be sure to delete the white space at the bottom (?>) and top <?php of the page. Hope this helps.

Cheers,
Rob