Jump to content

RockFinder2 - combine the power of PW selectors and SQL

Recommended Posts

RockFinder2 is the successor to RockFinder v1 and while the changes might not look that big on first sight they are quite huge behind the scenes. In RockFinder1 I used some kind of custom query builder because I didn't know of PW's built in one (see later). RockFinder2 will exist besides RockFinder1 because I have several projects relying on RockFinder1, but for any future projects you should definitely use RockFinder2.

This is how RF2 builds the SQL query:


So this is really easy to grasp, easy to maintain and easy to extend (like aggregations, selecting distinct values etc).

RockFinder2 also comes with a custom UI where you can manage your Finders:


You can then easily access those finders by name:


This is a soft alpha release. The module can be downloaded from https://github.com/BernhardBaumrock/RockFinder2 and the docs are at the moment a mess. I'll work on several useful examples in the next weeks that showcase all the features.


  • Like 26
  • Thanks 2

Share this post

Link to post
Share on other sites

Just added support to hide columns in the final output. Before I've always hidden those columns via JavaScript in the final table, but if you don't need them, why not removing them from the result before transmitting them to the client?

Now it is as simple as that - and the example also shows the new concept for single-page-reference joins which I really enjoy using as it is so much clearer than in RockFinder1:

$rf = new RockFinder2();
$rf->addColumns(['title', 'wife']); // wife is a single page reference

// find all wifes
$wives = new RockFinder2();
$rf->addJoin($wives, 'wife');

Result so far:

 id | title  | wife | wife:title
 11 | John   | 22   | Sue

Hide the wife column (the page id of wife pagefield):

 id | title  | wife:title
 11 | John   | Sue


  • Like 8

Share this post

Link to post
Share on other sites
14 hours ago, bernhard said:

Hide the wife


Just kidding...I'm loving this module and the improvements! Great work :-).

  • Haha 3

Share this post

Link to post
Share on other sites

Thx @kongondo I'm also really loving it already. RockFinder1 felt complex in comparison and every added feature added more complexity to id. Now using the queryselector syntax things got a LOT easier and therefore a lot more solid, eg https://github.com/BernhardBaumrock/RockFinder2/commit/6ca0937a499259afe46745ef4cce4486fdc9443d

  • Like 3

Share this post

Link to post
Share on other sites

Pushed a fix for RockMarkup2 and related modules (RockTabulator) not working in subdir installations. RockFinder2 was also affected because of the wrong api endpoint url.

  • Like 2
  • Thanks 1

Share this post

Link to post
Share on other sites

Just added support for sending variables to getByName()

// RockTabulator grid setup, eg dogs.php
$dogs = new RockFinder2();
$dogs->getByName('animals', ['type' => 'dog']);

// finder setup, eg animals.php
if(!$type) $type = "cat|dog";
$rf = new RockFinder2();
return $rf;

Also added a simple orGroups() method (see https://github.com/processwire/processwire-requests/issues/331😞

$rf = new RockFinder2();

// setup selector
$selector = ['parent' => '/foo/bar'];

if($from AND $to) {
  // show items that are not in the future
  $selector[] = ['date_start', '<', $to];

  // show items that ended this year or not yet
  $rf->orGroup($selector, [
    ['date_end', '>=', $from],
    ['date_end', '=', ''],



  • Like 1

Share this post

Link to post
Share on other sites

Now you can join any finder to any column of another finder. That's quite powerful but might also get complicated or slow... It's especially handy when you want to use RockFinder2 as datasource of a RockGrid, because RockGrid does not support the new concept of relations that where introduced to RockTabulator



  • Like 3

Share this post

Link to post
Share on other sites

Hi @bernhard,

I gave this module a try to see if it might be a good way to get data for a CSV download (on the front-end). But I'm having trouble getting off the ground.

I installed the module, put some demo code in my template file...

$rf = new RockFinder2();
$rf->find("id>2, limit=5");

...and I get this error:


The same code seems to execute in the Tracy Console in the back-end without an error. Is this module only for use in the PW admin?

I had trouble understanding the GitHub readme - are those just notes to yourself? It wasn't clear to me how the SQL examples at the top of the readme relate to the module, and several of the code examples use "new RockFinder()" when this module class is RockFinder2. 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...