Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active July 3, 2019 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/add97fad94fcf2629b0047aca96b559b to your computer and use it in GitHub Desktop.
Save hissy/add97fad94fcf2629b0047aca96b559b to your computer and use it in GitHub Desktop.
#concrete5 Ignore permission for rss feed

By default, concrete5 checks the permission of all of the pages in the RSS feed. If all pages are not viewable by a guest user, RSS feed will return 404 error page.

With this override, concrete5 never check any permission of all pages in the feed. This is useful to provide an RSS feed from a members-only website, but please keep in mind that all published pages will be included in the RSS feed with any permission settings.

Tested on concrete5 8.5.1

<?php
// Upload this file to application/controllers/feed.php
namespace Application\Controller;
use Concrete\Core\Http\ResponseFactoryInterface;
use Concrete\Core\Page\Feed as PageFeed;
class Feed extends \Concrete\Controller\Feed
{
public function output($identifier)
{
$responseFactory = $this->app->make(ResponseFactoryInterface::class);
if ($feed = PageFeed::getByHandle($identifier)) {
$feed->ignorePermissions(); // Ignore all permissions
if ($xml = $feed->getOutput($this->request)) {
return $responseFactory->create($xml, 200, ['Content-Type' => 'text/xml']);
}
}
return parent::output($identifier);
}
}
<?php
// Upload this file to application/routes/rss.php
defined('C5_EXECUTE') or die("Access Denied.");
$router->get('/rss/{identifier}', 'Application\Controller\Feed::output')
->setName('rss');
$router->get('/ccm/calendar/feed/{identifier}', 'Concrete\Controller\CalendarFeed::view')
->setName('calendar_rss');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment