Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Tutorial 2 RSS-Feed Error

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

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

Page: 1
Go to End
Author Topic: 2140 Views
  • zehjot
    Avatar
    Community Member
    6 Posts

    Tutorial 2 RSS-Feed Error Link to this post

    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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Tutorial 2 RSS-Feed Error Link to this post

    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

  • zehjot
    Avatar
    Community Member
    6 Posts

    Re: Tutorial 2 RSS-Feed Error Link to this post

    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?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Tutorial 2 RSS-Feed Error Link to this post

    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

  • zehjot
    Avatar
    Community Member
    6 Posts

    Re: Tutorial 2 RSS-Feed Error Link to this post

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

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: Tutorial 2 RSS-Feed Error Link to this post

    Hi zehojt!

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

  • ezero
    Avatar
    Community Member
    7 Posts

    Re: Tutorial 2 RSS-Feed Error Link to this post

    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

  • Chip Designs
    Avatar
    Community Member
    15 Posts

    Re: Tutorial 2 RSS-Feed Error Link to this post

    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

    2140 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.