ProcessWire - RockFinder (Module)
RockFinder Einführung[Bearbeiten]
RockFinder vereinfacht das Erstellen von komplexen SQL Statements. Damit lassen sich einfacher komplexe und effektive Datenbankabfragen erzeugen.
Normale ProcessWire Selektoren mit $pages->find()haben den Nachteil, dass sie sehr viel Speicher benötigen und langsam sind. Es gibt noch die Funktion findMany() die deutlich effektiver ist aber denoch die Seitenergebnisse in den Speicher lädt (wenn auch nicht alle auf einmal) in manchen Fällen möchte man lieber direkt SQL-Statements ausführen. Das bringt gerade bei komplexen Joins und großen Datenbeständen viel Performance. RockFinder erzeugt im Prinzip aus einfachen Selektoren komplexe SQL Statements. Außerdem bringt RockFinder auch bei der Rückgabe wieder page Objekte, so dass man sich hier viel Arbeit spart.
Statements lassen sich im Backend testen.
Links[Bearbeiten]
https://processwire.com/talk/topic/19226-rockfinder-highly-efficient-and-flexible-sql-finder-module/ https://modules.processwire.com/modules/rock-finder/ https://github.com/BernhardBaumrock/RockFinder
Beispiele[Bearbeiten]
Basic Usage[Bearbeiten]
$finder = new RockFinder('template=invoice, limit=3',['value','date'];
$finder->getObjects();
d($finder->getObjects()); // ausgabe mit debbuger funktion d
SQL Statement generieren[Bearbeiten]
$finder = new \ProcessWire\RockFinder('id>0, limit=5', ['title', 'status']);
return $finder->getSQL();
RockGrid[Bearbeiten]
RockGrid ist der Companion zu RockFinder und ist im Prinzip ein Listing Modul für das Backend. Es ist auch eine Frontendausgabe möglich.
Links[Bearbeiten]
https://gitlab.com/baumrock/FieldtypeRockGrid/wikis/quickstart
Quickstart[Bearbeiten]
his is an example setup on a fresh "Default Intermediate" installation.
- Edit the home template and add a new RockGrid field called rockgriddemo
- You'll find the new field on the home page edit screen.
- Add data to your RockGrid: Open the Details tab and see the usage instructions.
- Copy the example PHP code and you'll see data in your RockGrid
- Modify the Grid to your needs via JavaScript
document.addEventListener('RockGridItemBeforeInit', function(e) {
if(e.target.id != 'RockGridItem_rockgriddemo') return;
var grid = RockGrid.getGrid(e.target.id);
// set fixed column width
var col = grid.getColDef('id');
col.headerName = 'ID';
col.width = 70;
col.suppressSizeToFit = true;
col.suppressFilter = true;
var col = grid.getColDef('title');
col.headerName = 'Page Title';
var col = grid.getColDef('created');
col.headerName = 'Page Created Time';
// add coldef plugins (shortcuts for dates, numbers, etc)
grid.addColDefPlugins({
created: {name: 'date', format: 'DD.MM.YYYY HH:mm:ss'},
});
});
You can also add the Grid to the frontend: Just add $page->rockgriddemo to home.php:
Note that RockGrid is definitely intended to be used in the backend. I tried to make it easy to use it in the frontend as well, but some plugins are still not tested on the frontend and may need dependencies only available in the backend by default (like jQuery, for example).
Further instructions
Please see all the readme files in the module's repository. Most of the time you'll find a readme.md with general instructions and related myplugin.md files for plugins, coldefs etc. I did my best, but the docs are still far from perfect - any contribution via PRs is welcome ;) See the agGrid Docs for the endless possibilities you get when using agGrid. See the forum post for further help