More problems... CMS Errors

The Microblogging template previews without issue,

I followed the setup in Dev Diary 93 but on a clean project. I’m obviously missing something which doesn’t seem to be obvious and I could not find out from the documentation or the dev diary videos (which sorely need to be created and updated)

If I create a new project, add in a collection linked to a folder with 2 .md posts, and then try and preview the page after setting single text component to read {{item.title}} I get the following in the browser…

$collectionPath, ‘page_path’ => $pagePath, ‘pretty_urls’ => $prettyUrls, ‘title’ => htmlspecialchars(‘My Website - posts’, ENT_QUOTES, ‘UTF-8’), ‘description’ => htmlspecialchars(‘RSS feed for posts’, ENT_QUOTES, ‘UTF-8’), ‘link’ => ‘’ ]; $rssURL = $apiPath . ‘/cms/rss?’ . http_build_query($rssURLParams); $sitemapURLParams = [ ‘content_path’ => $collectionPath, ‘page_path’ => $pagePath, ‘pretty_urls’ => $prettyUrls, ‘base_url’ => ‘’ ]; $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, ‘filters’ => $filters, ‘orderBy’ => $orderBy, ‘orderDirection’ => $orderDirection, ‘collectionPath’ => $collectionPath, ‘pagePath’ => $pagePath, ‘itemsPerPage’ => $itemsPerPage, ‘prettyUrls’ => $prettyUrls, ‘collectionItemTemplateId’ => $collectionItemTemplateId ?? null ]); ?>

{{item.title}}

each(function ($item) use ($collection, $collectionItemTemplate, $filters, $orderBy, $orderDirection, $collectionPath, $pagePath, $itemsPerPage, $prettyUrls, $collectionItemTemplateId) { echo renderTemplate($collectionItemTemplate, [ ‘item’ => $item, ‘collection’ => $collection, ‘filters’ => $filters, ‘orderBy’ => $orderBy, ‘orderDirection’ => $orderDirection, ‘collectionPath’ => $collectionPath, ‘pagePath’ => $pagePath, ‘itemsPerPage’ => $itemsPerPage, ‘prettyUrls’ => $prettyUrls, ‘collectionItemTemplateId’ => $collectionItemTemplateId ]); }); // Output the template for use in frontend Alpine components echo ‘’; ?>

$collection->pagination, ‘items’ => $collection->items, ‘collection’ => $collection, ‘filters’ => $filters, ‘orderBy’ => $orderBy, ‘orderDirection’ => $orderDirection, ‘collectionPath’ => $collectionPath, ‘pagePath’ => $pagePath, ‘itemsPerPage’ => $itemsPerPage, ‘prettyUrls’ => $prettyUrls, ‘collectionItemTemplateId’ => $collectionItemTemplateId ]); ?>

Have you set the page to be PHP?

2 Likes

Well that needs to be made much more obvious !

Again, the documentation is lacking heavily, as is any kind of beginner type of video / help.

Spent hours looking at this today, and just needed to change the .html to .php - better docs would have stopped me and I am sure others from wasting their time.

The whole thing feels like a beta project, needs a lot more spit and polish for me to see it as feasible for even basic sites.

It’s the problem when coders create something but never really think about how the masses will use it :frowning:

1 Like

See section: PHP Page extension

1 Like

Burried deep within the docs, very helpful that.

Would make more sense if it was flagged up open the CMS pages of the documentation in big bold letters!

Again, devs writing like devs and not thinking about this without their knowledge.