Open herrajon opened 4 years ago
Howdy Folks
Sea trialing this smart looking flat filed WCMS. Love it. We could have future together.
Ventured off into to creating a json-feed based on instructions here (How to use a controller to create a JSON feed).
Done everything by the book, but it breaks when I add title to the soup. If I let that alone then it renders nicely the content and URLs.
I must be missing something obvious or have things changed since the docs were written?
It franticly complains about: "Undefined property: Statamic\Data\Entries\Entry::$title"
(Added title to the getItems function and the Statamic\API\Entry line)
<?php namespace Statamic\SiteHelpers; use Statamic\Extend\Controller as AbstractController; use Statamic\API\Entry; class FeedController extends AbstractController { /** * @return mixed */ public function json() { return [ 'version' => 'https://jsonfeed.org/version/1', 'title' => 'My Awesome Site', 'home_page_url' => 'https://my-awesome-site.com/', 'feed_url' => 'https://my-awesome-site.com/feed.json', 'items' => $this->getItems() ]; } private function getItems() { return Entry::whereCollection('content-template')->map(function ($entry) { return [ 'id' => $url = $entry->url(), 'url' => $url, 'title' => $entry->title, 'content_html' => markdown($entry->content()), ]; })->all(); } }
Truly Herra Jón
Howdy Folks
Sea trialing this smart looking flat filed WCMS. Love it. We could have future together.
Ventured off into to creating a json-feed based on instructions here (How to use a controller to create a JSON feed).
Done everything by the book, but it breaks when I add title to the soup. If I let that alone then it renders nicely the content and URLs.
I must be missing something obvious or have things changed since the docs were written?
It franticly complains about: "Undefined property: Statamic\Data\Entries\Entry::$title"
Code from FeedController.php
(Added title to the getItems function and the Statamic\API\Entry line)
Truly Herra Jón