Skip to content

Commit

Permalink
Fix error when calling from templates (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Nov 15, 2018
1 parent e2305ff commit 288a1b4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/services/DataTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use verbb\feedme\datatypes\Xml;
use verbb\feedme\events\FeedDataEvent;
use verbb\feedme\events\RegisterFeedMeDataTypesEvent;
use verbb\feedme\models\FeedModel;

use Craft;
use craft\base\Component;
Expand Down Expand Up @@ -289,19 +290,19 @@ public function getFeedForTemplate($options = [])
return [];
}

$settings = [];
$feed = new FeedModel();
$dataType = $this->getRegisteredDataType($type);

if ($element) {
$settings['primaryElement'] = $element;
$feed->primaryElement = $element;
}

// If cache explicitly set to false, always return latest data
if ($cache === false) {
if ($headers) {
$data = $this->_headers;
} else {
$data = Hash::get($dataType->getFeed($url, $settings), 'data');
$data = Hash::get($dataType->getFeed($url, $feed), 'data');
}

if ($offset) {
Expand All @@ -327,7 +328,7 @@ public function getFeedForTemplate($options = [])
if ($headers) {
$data = $this->_headers;
} else {
$data = Hash::get($dataType->getFeed($url, $settings), 'data');
$data = Hash::get($dataType->getFeed($url, $feed), 'data');
}

if ($offset) {
Expand Down

0 comments on commit 288a1b4

Please sign in to comment.