RSS Feed/News Limit and shuffle finder results

Status
Not open for further replies.

ENXF NET

Administrator
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P.S Member
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Nov 13, 2018
Messages
26,860
Points
823

Reputation:

Hi
I have a finder for some categories and I want to shuffle the results and limit them.
Since I don't want to always return the first x of the results, I am not limiting in the finder itself.

My code is as follows:

PHP:

Code:
$categoryFinder = $this->finder('****')
    ->where('category_id', $categoryIds);

$categories = $categoryFinder->fetch();
$categories = $categories->shuffle();

$categories = $categories->slice(0, $limit);

I am wondering if there is a better (built in maybe?) way to do...

Read more

Continue reading...
 
Status
Not open for further replies.
Top