diff --git a/src/behaviors/RecentlyViewedBehavior.php b/src/behaviors/RecentlyViewedBehavior.php index 358a3f9..499bd01 100644 --- a/src/behaviors/RecentlyViewedBehavior.php +++ b/src/behaviors/RecentlyViewedBehavior.php @@ -63,7 +63,6 @@ public function beforePrepare(): bool $allCases .= 'WHEN elements.id=' . $anId . ' THEN ' . $count . ' '; $count++; } - var_dump($allCases); $this->owner->subQuery->orderBy([new \yii\db\Expression( 'CASE ' . $allCases . ' END' )]); diff --git a/src/services/Queries.php b/src/services/Queries.php index 713a62c..8c72587 100755 --- a/src/services/Queries.php +++ b/src/services/Queries.php @@ -35,6 +35,8 @@ class Queries extends Component { + private $maxRecentHistory = 99; + public function clear() { Craft::$app->getSession()->set('rv-recent-ids', []); @@ -60,6 +62,9 @@ public function trackId($id) unset($recentIds[$key]); } $recentIds[] = $id; + if(sizeof($recentIds) > $this->maxRecentHistory){ + $recentIds = array_slice($recentIds, - $this->maxRecentHistory); + } Craft::$app->getSession()->set('rv-recent-ids', $recentIds); } }