diff options
| author | horus | 2021-02-12 16:04:53 +0100 |
|---|---|---|
| committer | horus | 2021-02-12 16:04:53 +0100 |
| commit | ce874f4a8f484ae81df867399cdb85a9cf1b9fa3 (patch) | |
| tree | 631d016465a3dde047bf90b5f09793b1b1e6693f /app/Libraries | |
| parent | 87b5264cdc451f4268722e670a6f77d8e3d1c334 (diff) | |
| download | curious-ce874f4a8f484ae81df867399cdb85a9cf1b9fa3.tar.gz | |
Fix Feeds.
Diffstat (limited to 'app/Libraries')
| -rw-r--r-- | app/Libraries/Helper.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/app/Libraries/Helper.php b/app/Libraries/Helper.php index 69e7de6..be055b9 100644 --- a/app/Libraries/Helper.php +++ b/app/Libraries/Helper.php @@ -53,7 +53,7 @@ class Helper { $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon' $feed->pubdate = $model[0]->created_at; $feed->lang = 'en'; - $feed->setShortening(true); // true or false + $feed->setShortening(false); // true or false $feed->setTextLimit(100); // maximum length of description text foreach ($model as $post) @@ -61,13 +61,15 @@ class Helper { $desc = ($post->excerpt_html); - $categories = "<br>"; - foreach( $post->getCategories()->get() as $cat ) { - $categories .= "<a href='". \URL::to('/topic/' . $cat->name) ."'>". $cat->name . "</a> | "; + if ( ! $post->getCategories()->get()->isEmpty() ) { + $categories = "<br>"; + foreach( $post->getCategories()->get() as $cat ) { + $categories .= "<a href='". \URL::to('/topic/' . $cat->name) ."'>". $cat->name . "</a> | "; + } + $categories = rtrim($categories, " | "); + $desc .= "<br>Topics:"; + $desc .= $categories; } - $categories = rtrim($categories, " | "); - $desc .= "<br>Topics:"; - $desc .= $categories; $discussions = "<br>"; foreach( $post->getDiscussions()->orderBy('comments', 'desc')->get() as $dis ) { @@ -78,7 +80,15 @@ class Helper { $desc .= $discussions; // set item's title, author, url, pubdate, description, content, enclosure (optional)* - $feed->add($post->title, env('APP_NAME'), \URL::to($post->url), $post->created_at, $desc, $desc); + $feed->addItem([ + 'title' => $post->title, + 'author' => env('APP_NAME'), + 'url' => \URL::to($post->url), + 'link' => \URL::to($post->url), + 'pubdate' => $post->created_at, + 'description' => $desc, + 'content' => $desc + ]); } } |
