I would like to make more “Feed” page from differentes RSS
(I add a Rss property in .txt, and use $this->rss() in models/rssfeed.php)
I can manage Kirby page with folder and files, it’s work !
But when I try to add page from the panel, if I choose Feed in model, I have
’ malformed’ on save.
Hm, I think I’m missing something here but I don’t quite know what. What is this about RSS property iin.txtand how does it relate to your blueprint? Apart from the fact that your have a section that lists pages with therssfeed` template.
and my “models”, if I rename it, no malformed message
class RssfeedPage extends Page {
public function children()
{
$results = [];
$pages = [];
$request = Remote::get($this->rss());
// if the request was sucessfully, parse feed as $results
if ($request->code() === 200) {
$results = Xml::parse($request->content());
}
// if we have any results, create the child page props for each result
if (count($results) > 0) {
foreach ($results['channel']['item'] as $item) {
$cat = is_array($item['category']) ? implode(', ', $item['category']) : $item['category'];
$pages[] = [
'slug' => Str::slug($item['title']),
'template' => 'feeditem',
'model' => 'feeditem',
'content' => [
'title' => $item['title'],
'date' => $item['pubDate'] ?? '',
'description' => $item['description'] ?? '',
'link' => $item['link'] ?? '',
'categories' => $cat,
'author' => $item['dccreator'] ?? '',
'enclosure' => $item['enclosure']['@attributes']['url'] ?? '',
]
];
}
}
// create a Pages collection for the child pages
return Pages::factory($pages, $this);
}
}
This is a factory problems, may be, I don’t really need virtuals childrens links ; I can deal with Pages::anotherWordIdontKnow($pages) to uses array like kirby field ?
OK, I don’t understand all Kirby Class, children is reserved ?
RSS will be fill after adding a page and choose “feed” models so
As I understand with your help @texnixe
$request = Remote::get($this->rss());
Just do this trick : $request = Remote::get($this->rss()->or('https://any.fr/rss'));