Oke so I got good help from Pathologic. You might need to modify some items.
Snippet: "Feed"
<?php
if (empty($input)) return;
if (isset($_GET['im_id']) && is_numeric($_GET['im_id'])) {
$input .= $_GET['im_id'];
}
$wrapTpl = $wrapTpl ?? '@CODE:[+wrap+]';
$tpl = $tpl ?? '@CODE:<h2>[+title+]</h2><div><small>[+pubdate+]</small><div>[+content+]</div>';
$display = $display ?? 10;
$dateFormat = $dateFormat ?? 'd.m.Y';
/* this below might be needed for EVO 1
if (!class_exists('SimplePie\SimplePie')) {
require_once(MODX_MANAGER_PATH . 'media/rss/vendor/autoload.php');
}
include_once(MODX_BASE_PATH . 'assets/snippets/DocLister/lib/DLTemplate.class.php');
*/
$DLTemplate = DLTemplate::getInstance($modx);
$feed = new SimplePie\SimplePie();
$feedCache = MODX_BASE_PATH . 'assets/cache/rss';
if (!is_dir($feedCache)) {
@mkdir($feedCache);
}
$feed->set_cache_location($feedCache);
$out = '';
$feed->set_feed_url($input);
$feed->init();
$items = $feed->get_items(0, $display);
if (empty($items)) {
return;
}
foreach ($items as $item) {
$plh = [
'id' => $item->data['child']['']['id'][0]['data'] ?? $item->get_id(),
'href' => $item->get_link(),
'title' => $item->get_title(),
'pubdate' => date($dateFormat, strtotime($item->get_date())),
'content' => $item->get_content(),
'description' => $item->get_description(),
'introduction' => Illuminate\Support\Str::words(strip_tags($item->get_content()), 45),
'image' => $item->data['child']['']['image'][0]['data'] ?? ''
];
$out .= $DLTemplate->parseChunk($tpl, $plh);
}
if (!empty($out)) $out = $DLTemplate->parseChunk($wrapTpl, ['wrap' => $out]);
return $out;
Overview page:
[!Feed?
&input=`https://some-urlcom/rss/customfeed.aspx`
&tpl=`@CODE:<img src="[+image+]" /><h2>[+title+]</h2><div><small>[+pubdate+]</small><div>[+introduction+] <a href="https://some-site.com/feed-detail?im_id=[+id+]">read more</a></div>`
&display=`7`
!]
Detailpage:
[!Feed?
&input=`https://some-urlcom/rss/customfeed.aspx`
&tpl=`@CODE:<img src="[+image+]" /><h2>[+title+]</h2><div><small>[+pubdate+]</small><div>[+content+] <a href="[~41~]">back</a></div>`
&display=`1`
!]