$collectionPath,
'page_path' => $pagePath,
'pretty_urls' => $prettyUrls,
'title' => htmlspecialchars('Innovation PRAXIS - Posts', ENT_QUOTES, 'UTF-8'),
'description' => htmlspecialchars('RSS feed for Posts', ENT_QUOTES, 'UTF-8'),
'link' => 'https://wp1125317.server-he.de'
];
$rssURL = $apiPath . '/cms/rss?' . http_build_query($rssURLParams);
$sitemapURLParams = [
'content_path' => $collectionPath,
'page_path' => $pagePath,
'pretty_urls' => $prettyUrls,
'base_url' => 'https://wp1125317.server-he.de'
];
$sitemapURL = $apiPath . '/cms/sitemap?' . http_build_query($sitemapURLParams);
if ($wantsRSS) {
echo '';
}
if ($wantsSitemap) {
echo '';
}
})();
?>
is_array($_GET['tags'] ?? '')
? $_GET['tags']
: array_filter(array_map('trim', explode(',', $_GET['tags'] ?? ''))),
default => array_filter(array_map('trim', explode(',', '')))
};
if (!empty($tags)) {
$filters['tags'] = implode(',', $tags);
}
}
// Author filtering
$filterAuthor = "all";
if ($filterAuthor !== 'all') {
$author = match ($filterAuthor) {
'url' => is_array($_GET['author'] ?? '')
? $_GET['author']
: array_filter(array_map('trim', explode(',', $_GET['author'] ?? ''))),
default => array_filter(array_map('trim', explode(',', '')))
};
if (!empty($author)) {
$filters['author'] = implode(',', $author);
}
}
// Featured filtering
$filterFeatured = "all";
if ($filterFeatured !== 'all') {
$filters['featured'] = $filterFeatured === 'true' ? 'true' : 'false';
}
// Status filtering
$filterStatus = "published";
if ($filterStatus !== 'all') {
$filters['status'] = $filterStatus;
} else {
$filters['status'] = 'published'; // Default to published only
}
// Date filtering - handled via API query parameters
$filterDate = "past";
if ($filterDate === 'past') {
$filters['date_before'] = date('Y-m-d H:i:s');
} elseif ($filterDate === 'future') {
$filters['date_after'] = date('Y-m-d H:i:s');
}
$orderBy = "date";
$orderDirection = "desc";
// Build collection query using fluent API with URL configuration
$ECMS_options = [
'resources' => [
'path' => '../resources'
]
];
$query = cms($ECMS_options)->collection($collectionPath)
->pagePath($pagePath)
->tagPagePath('')
->authorPagePath('')
->prettyUrls($prettyUrls)
->orderBy($orderBy, $orderDirection);
// Apply all filters
foreach ($filters as $key => $value) {
switch ($key) {
case 'tags':
$query = $query->tags($value);
break;
case 'author':
$query = $query->author($value);
break;
case 'featured':
$query = $query->featured($value === 'true');
break;
case 'status':
$query = $query->status($value);
break;
case 'date_before':
$query = $query->before($value);
break;
case 'date_after':
$query = $query->after($value);
break;
}
}
// Execute query with pagination
try {
$collection = $query
->paginate($currentPage, $itemsPerPage)
->get();
$items = $collection->items;
$pagination = $collection->pagination;
} catch (Exception $e) {
$items = [];
$pagination = (object) [
'current_page' => 1,
'total_pages' => 1,
'total_items' => 0,
'items_per_page' => $itemsPerPage,
'has_prev' => false,
'has_next' => false
];
}
// Create collection-like object for backward compatibility
$collectionObj = new class($items, $pagination) {
public $items;
public $pagination;
public function __construct($items, $pagination)
{
$this->items = $items;
$this->pagination = $pagination;
}
public function each($callback)
{
foreach ($this->items as $item) {
$callback($item);
}
}
};
// Collection data is now available in template scope
$collection = $collectionObj;
?> $collection->pagination,
'items' => $collection->items,
'collection' => $collection
]);
?>
{{item.title}}
each(function ($item) use ($collection, $collectionItemTemplate) {
echo renderTemplate($collectionItemTemplate, [
'item' => $item,
'collection' => $collection
]);
});
// Output the template for use in frontend Alpine components
echo '
';
echo $collectionItemTemplate;
echo '';
?>
$collection->pagination,
'items' => $collection->items,
'collection' => $collection
]);
?>