About RockFinder2

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.

Category Admin Helpers
Admin helper modules are those that provide helpful tools, UI enhancements or optimizations to the admin panel (excluding Fieldtype or Inputfield modules).
Release StateBeta
Close to stable, but users are advised to be cautious and test thoroughly.*
Authorbernhardbaumrock
Module Version0.0.4
Class NameRockFinder2
Compatibility3.0
Date AddedApril 23, 2020
Recommended ByNew recommendations may take up to 1 day to appear.

Instructions

This module's files should be placed in /site/modules/RockFinder2/
How to install or uninstall modules

README

RockFinder2

ProcessWire module, successor of RockFinder


Sorry for this readme! It is really not more then notes to myself. I hope I can provide a proper readme one day :)


$f = new RockFinder2();
$f->find('template=admin');
$f->addColumns(['title']);
db($f);

img


How to create custom column types

It is really easy to create custom column types that can retrieve any data from the PW database. See this commit for two simple examples: https://github.com/BernhardBaumrock/RockFinder2/commit/54476a24c78ae4d3b6d00f8adfb2c8cd9d764b9d

If the fieldtype is of broader interest please consider making a PR. If you are the only one needing it add the type via hook.

Adding a custom column type is as simple as this:

$f->addColumns(['FieldOptionsValue:your_options_fieldname']);

Manually joining any kind of data

$f = new RockFinder2();
$f->find('template=basic-page, include=all');
$f->addColumns(['title', 'options']);
$f->query->select("opt.value AS `options.value`");
$f->query->leftjoin("fieldtype_options AS opt ON opt.option_id = _field_options.data");
db($f->getData()->data);

img

Dumping the query object will be really helpful on such tasks!

img

You can also replace the field's value instead of adding it to the result:

$f = new RockFinder2();
$f->find('template=basic-page, include=all');
$f->addColumns(['title', 'options']);

$select = $f->query->select;
unset($select[2]);
$f->query->set('select', $select);


$f->query->select("opt.value AS `options`");
$f->query->leftjoin("fieldtype_options AS opt ON opt.option_id = _field_options.data");
db($f->query);
db($f->getData()->data);

img