Closed Splendorr closed 5 years ago
Here's my entire feed config.php in case that's helpful:
[
'pattern' => 'posts/feed',
'method' => 'GET',
'action' => function () {
$options = [
'title' => 'POSTS by Nick Splendorr',
'description' => 'The most recent POSTS.',
'link' => 'posts',
'textfield' => 'text',
];
$feed = page('posts')->children()->listed()->flip()->limit(20)->feed($options);
return $feed;
}
]
i will take a look today.
since this plugin is more or less just a port of the k2 plugin from @bastianallgeier i kept the sorting by datefield logic:
https://github.com/bnomei/kirby3-feed/blob/master/classes/Feed.php#L83
since you want to sort using the num you should use 'datefield' => 'num',
in the options array.
see https://getkirby.com/docs/reference/objects/page/num
you could use sort
instead if num
but that would return the num
anyway.
https://getkirby.com/docs/reference/objects/page/sort#no-parameter
note: if there is no field called date
the modified timestamp will be used.
with version 1.3.0
you can now disable the build in sorting in adding the 'sort'=> false
to the array of options you forward the ->feed($options)
.
Hi! I really appreciate this plugin and am using it currently on a personal blog. I'm just having trouble with the sort order, in what seems like a straightforward scenario: I want the feed to sort by listed()->flip(). I just want to see the posts, from newest to oldest, according to their numerical post order.
(I've tried sorting by date and time, but for certain reasons I'd like to just sort my posts by their Kirby folder number order.)
I've had some trouble getting this simple-seeming configuration working in a few places, and it seems to relate to having more than one post per day. Here's what I'm seeing:
I have 3 posts, each set to Public, which I named first, second, and third, in the order they were created and published. You can see their folders are in order (25, 26, 27) and their titles correspond.
In my template, I'm using
<?php $articles = $page->children()->listed()->flip()->paginate(10) ?>
to display the posts in flipped order. This works in the template:However, when I use
$feed = page('posts')->children()->listed()->flip()->limit(20)->feed($options);
for the feed, it returns the following:Now, you can see the last item is from an earlier date, in the right order. I can see in the feed output that the problem is probably related to all of their pubDates being identical... but they are being output in the wrong order somehow vs the way flip() works in the template.
Do you have any advice or tips? Thanks for your time either way!