src/Controllers/CommentingController.php
public function getFeed(HTTPRequest $request)
    {
        $link = $this->Link('rss');
        $class = $this->decodeClassName($request->param('ID'));
        $id = $request->param('OtherID');

        // Support old pageid param
        if (!$id && !$class && ($id = $request->getVar('pageid'))) {
            $class = SiteTree::class;
        }

        $comments = Comment::get()->filter([
            'Moderated' => 1,
            'IsSpam' => 0,
        ]);

        // Check if class filter
        if ($class) {
            if (!is_subclass_of($class, DataObject::class) || !$class::has_extension(CommentsExtension::class)) {
                return $this->httpError(404);
            }
            $this->setParentClass($class);
            $comments = $comments->filter('ParentClass', $class);
            $link = Controller::join_links($link, $this->encodeClassName($class));

            // Check if id filter
            if ($id) {
                $comments = $comments->filter('ParentID', $id);
                $link = Controller::join_links($link, $id);
                $this->setOwnerRecord(DataObject::get_by_id($class, $id));
            }
        }

        $title = _t(__CLASS__ . '.RSSTITLE', "Comments RSS Feed");
        $comments = PaginatedList::create($comments, $request);
        $comments->setPageLength($this->getOption('comments_per_page'));

        return RSSFeed::create(
            $comments,
            $link,
            $title,
            $link,
            'Title',
            'EscapedComment',
            'AuthorName'
        );
    }
public function getFeed(HTTPRequest $request)
    {
        $link = $this->Link('rss');
        $class = $this->decodeClassName($request->param('ID'));
        $id = $request->param('OtherID');

        // Support old pageid param
        if (!$id && !$class && ($id = $request->getVar('pageid'))) {
            $class = SiteTree::class;
        }

        $comments = Comment::get()->filter([
            'Moderated' => 1,
            'IsSpam' => 0,
        ]);

        // Check if class filter
        if ($class) {
            if (!is_subclass_of($class, DataObject::class) || !$class::has_extension(CommentsExtension::class)) {
                return $this->httpError(404);
            }
            $this->setParentClass($class);
            $comments = $comments->filter('ParentClass', $class);
            $link = Controller::join_links($link, $this->encodeClassName($class));

            // Check if id filter
            if ($id) {
                $comments = $comments->filter('ParentID', $id);
                $link = Controller::join_links($link, $id);
                $this->setOwnerRecord(DataObject::get_by_id($class, $id));
            }
        }

        $title = _t(__CLASS__ . '.RSSTITLE', "Comments RSS Feed");
        $comments = PaginatedList::create($comments, $request);
        $comments->setPageLength($this->getOption('comments_per_page'));

        return RSSFeed::create(
            $comments,
            $link,
            $title,
            $link,
            'Title',
            'EscapedComment',
            'AuthorName'
        );
    }
public function getFeed ( HTTPRequest $ request ) { $ link = $ this -> Link ( 'rss' ) ; $ class = $ this -> decodeClassName ( $ request -> param ( 'ID' ) ) ; $ id = $ request -> param ( 'OtherID' ) ; // Support old pageid param if ( ! $ id && ! $ class && ( $ id = $ request -> getVar ( 'pageid' ) ) ) { $ class = SiteTree :: class ; } $ comments = Comment :: get ( ) -> filter ( [ 'Moderated' => 1 , 'IsSpam' => 0 , ] ) ; // Check if class filter if ( $ class ) { if ( ! is_subclass_of ( $ class , DataObject :: class ) || ! $ class :: has_extension ( CommentsExtension :: class ) ) { return $ this -> httpError ( 404 ) ; } $ this -> setParentClass ( $ class ) ; $ comments = $ comments -> filter ( 'ParentClass' , $ class ) ; $ link = Controller :: join_links ( $ link , $ this -> encodeClassName ( $ class ) ) ; // Check if id filter if ( $ id ) { $ comments = $ comments -> filter ( 'ParentID' , $ id ) ; $ link = Controller :: join_links ( $ link , $ id ) ; $ this -> setOwnerRecord ( DataObject :: get_by_id ( $ class , $ id ) ) ; } } $ title = _t ( __CLASS__ . '.RSSTITLE' , "Comments RSS Feed" ) ; $ comments = PaginatedList :: create ( $ comments , $ request ) ; $ comments -> setPageLength ( $ this -> getOption ( 'comments_per_page' ) ) ; return RSSFeed :: create ( $ comments , $ link , $ title , $ link , 'Title' , 'EscapedComment' , 'AuthorName' ) ; }
Return an RSSFeed of comments for a given set of comments or all
comments on the website.

@param HTTPRequest

@return RSSFeed
Return an RSSFeed of comments for a given set of comments or all comments on the website .