Jump to content

Ryan's Blog site and RSS issues


benbyf
 Share

Recommended Posts

Hi!

Implemented Ryan's blog template to kickstart a site I was making for my own business and can't get to grips with the Abstraction of the RSS feed in it.

site: blog.eulergy.com/

rss: http://blog.eulergy.com/categories/resources/rss

notice that the dates are running in the wrong order old to new and not newest first. Anyone able to illustrate how one might change that in the blog template?

Thanks,

Link to comment
Share on other sites

think this is the rss section in the blog.inc

/**
 * Render an RSS feed
 *
 * Note that you should not output anything further after calling this, as it outputs the RSS directly.
 *
 * @param PageArray $items Pages to include in the feed
 * @param string $title Title of the feed. If not provided, pulled from current page.
 * @param string $description Description of the feed. If not provided, pulled from current page.
 *
 */
function renderRSS(PageArray $items, $title = '', $description = '') {

	$page = wire('page');
	if(empty($title)) $title = $page->get('headline|title') . ' - ' . wire('pages')->get('/')->headline;
	if(empty($description)) $description = $page->get('summary|meta_description');

	$rss = wire('modules')->get('MarkupRSS');
	$rss->title = $title;
	$rss->description = $description;
	$rss->itemDateField = 'date';
	$rss->render($items);
}

Link to comment
Share on other sites

  • 2 weeks later...
$posts = wire('pages')->find("template=post, sort=-date, $selector");

but im not sure if the renderRSS function uses the $posts available in blog.inc - I love the ease of use ryan's blog theme, but its totally obfuscated compared how i would normally template.

Link to comment
Share on other sites

think it might be an issue with the markupRSS.module in wire/modules as there doesnt seem to be any sorting (PW2.2):

/**
	 * Render the feed and return it
	 *
	 */
	public function renderFeed(PageArray $feedPages = null) {

		if(!is_null($feedPages)) $this->feedPages = $feedPages;

		$out = $this->renderHeader();

		foreach($this->feedPages as $page) {
			if(!$page->viewable()) continue;
			$out .= $this->renderItem($page);
                }

                $out .= "</channel>\n</rss>\n";

		return $out; 
	}
Link to comment
Share on other sites

There is no sorting in that module, it just handles the Pagearray as it is. Sort on date doesn't exists if you don't have a Datetime field called date.

if you want to sort on date created it's:

$posts = wire('pages')->find("template=post, sort=-created, $selector");

 if you want to sort on date modified it's:

$posts = wire('pages')->find("template=post, sort=-modified, $selector");

if you want to sort on a date field it's: (thats is what you've done now)

$posts = wire('pages')->find("template=post, sort=-nameofdatefield, $selector");
 
  • Like 1
Link to comment
Share on other sites

Mart, thanks!

I spent ages trying to find where renderRSS is being used in the template and finally tracked it down to the category.php file which is where the $posts is being defined. It's now sorted by date created and therefore showing on the main site in order (eulergy.com)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...