Jump to content
bernhard

RockFinder - Highly Efficient and Flexible SQL Finder Module

Recommended Posts

56 minutes ago, dragan said:

a) I can't get any RF output (arrays, objects) to play nice with PW's pagination / renderPager(). I guess pagination expects a PageArray, not just any kind of array. I know RF was never meant to be used in the frontend, but I tried anyway (and of course, I know building my own pagination with something like Tabulator is quite easy). I just wanted to compare an existing page (how much speed I would gain using RF instead of native PF find).

There's nothing wrong with using RF for the frontend, but you are right, pagination was not on my list. And I don't think we will ever need it for RockFinder, because if you are using pagination, you can use native PW find operations without any performance drawback.

59 minutes ago, dragan said:

url is not recognized. I guess because a PW page URL is not stored inside the DB as-is, but is created when calling the $page->url() method. Am I correct? (PW has to assemble parents(s), page-names etc.)

Exactly, that's why I implemented the callback feature where you can use the PW API to get any properties of your page via PHP: 

 

Share this post


Link to post
Share on other sites

Hi @dragan, I'm doing the same, using Rockfinder on the frontend, building my own pagination. b), 'url': since you know the parent (1041), you could query 'name' instead of 'url', and add it to the known path.

Share this post


Link to post
Share on other sites

Another option could be to build a redirect page, eg mysite.com/?id=1234 that redirects to this page, eg mysite.com/myparent/mypage - then you can easily and efficiently build your links via the ID property.

Share this post


Link to post
Share on other sites

@Lutz True. But maybe I'll have another setup where I need to query pages that live under different parents, and (theoretically) also could have identical page-names.

@bernhard Now that sounds both easy and awesome (plus "safe", in the sense that a page ID is always unique, while page-names aren't - unless they are children under the same parent page).

I've been playing a bit more with RF... pure awesomeness and fun. Together with Lazy Cron, Tabulator.js and RF, a small test-setup runs incredibly fast. (Lazy Cron to store the RF-output - JSON - once a day). Makes me almost sad I currently don't have a real use-case / client-project to use all this...

Share this post


Link to post
Share on other sites
43 minutes ago, dragan said:

@bernhard Now that sounds both easy and awesome (plus "safe", in the sense that a page ID is always unique, while page-names aren't - unless they are children under the same parent page).

Yeah - I've too often had to build complicated RockFinder queries and came up with this quick&easy solution one day and couldn't believe I didn't think of it earlier 😄

45 minutes ago, dragan said:

I've been playing a bit more with RF... pure awesomeness and fun. Together with Lazy Cron, Tabulator.js and RF, a small test-setup runs incredibly fast. (Lazy Cron to store the RF-output - JSON - once a day). Makes me almost sad I currently don't have a real use-case / client-project to use all this...

Don't tell anybody, but I've just started developing RockFinder2 with a new syntax that will be even easier to use and more intuitive and powerful 😉 

  • Like 7
  • Thanks 1

Share this post


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

Don't tell anybody

I won't 🙊🙉🙈

I just realized the "view" link in the RF Tester (zooming glass icon) seems to be hard-coded: it's assuming my PW backend is "admin". This should probably be defined dynamically instead (or at least configurable).

Also, I noticed the div.paginationPageSize is always showing "undefined" o_O

  • Like 1

Share this post


Link to post
Share on other sites
12 minutes ago, dragan said:

I just realized the "view" link in the RF Tester (zooming glass icon) seems to be hard-coded: it's assuming my PW backend is "admin".

Thx, fixed in 1.1.5

12 minutes ago, dragan said:

Also, I noticed the div.paginationPageSize is always showing "undefined" o_O

True, but I won't fix this as it's not critical and I want to focus on RockFinder2 + RockTabulator 🙂 

  • Like 2

Share this post


Link to post
Share on other sites

Is there an efficient way to get the template name or at least the template ID in the RockFinder results? I'm doing a query for all children of a particular page and those children can have different templates and I need to know which template each page has.

Excellent module btw 👍

Share this post


Link to post
Share on other sites

Hi @Marc Thx for that interesting question!

I've pushed a little update so that RockFinder takes a DatabaseQuerySelect object as find() parameter. You can then add your find as a relation to your finder:

NLqnwDt.png

Spoiler

$rf = new RockFinder2();
$rf->find("name=cat-50|dog-50");
$rf->addColumns(['title', 'templates_id']);

$query = new DatabaseQuerySelect();
$query->select('id,name');
$query->from('templates');
$templates = new RockFinder2();
$templates->find($query);
$rf->addRelation('templates', $templates);

db($rf);

 

Relations can be great for options fields or 1:n relationships. In this case we have 1:1 so a join would maybe make more sense (though have in mind that this creates one more row in the main resultset, so if you had 1000 rows that would mean 1000 more data items whereas in the relation it would be only the number of the templates).

You can join ANY sql to your initial finder quite easily. First analyze the query and resulting SQL:

7yp4n2n.png

We need two things:

1) LEFT JOIN the data
2) SELECT the column we need in the base query

UXJOw98.png

Voila 😎

1yq7rX2.png

  • Like 5

Share this post


Link to post
Share on other sites

I would like to try this out so I have just downloaded RockFinder2 from github, however even the simplest test won't work for me:

$rf = new RockFinder2();
$rf->find("parent=1");
$rf->addColumns(["title"]);

Using this on the front end, it generates the error "Uncaught Error: Call to a member function __invoke() on null in /site/modules/RockFinder2/RockFinder2.module.php:746". Also getting this notice: "Trying to get property of non-object in /site/modules/RockFinder2/RockFinder2.module.php on line 801"

RockFinder1 is working properly.

Share this post


Link to post
Share on other sites

Does it work in the backend? Do you have the latest version (git pull)? It looks like $RockFinder2 api variable is not available for you, but it should (the module is autoload).

SOd6fAT.png

  • Like 1

Share this post


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

Does it work in the backend? Do you have the latest version (git pull)? It looks like $RockFinder2 api variable is not available for you, but it should (the module is autoload).

You are correct, RockFinder2 was not available. I installed the module and ignored the TracyDebugger dependency warning. Since it DID successfully install ProcessRockFinder2, I assumed everything was alright. Anyway, I installed the debugger and reinstalled RockFinder2 and now it's up and running. Silly mistake on my part and sorry for bothering you about this!

I got your example of including the template name working, thanks for your help! I hope you won't mind if I ask you another question. The docs for RockFinder2 briefly mention repeaters, and state that columns musts be defined manually. What exactly do you mean by this? Could you provide an example? With RockFinder1 you can do $finder->addField("repeatername", ["fieldname"]) but this is no longer the case with RockFinder2.

Share this post


Link to post
Share on other sites

I haven't had a look into repeaters yet. I'm avoiding them at all for all my projects as they brought up several problems (especially for finding data via RockFinder). I have a lot more control using regular pages for that tasks and using RockGrid / RockTabulator for presentation and as GUI.

Though it should be quite easy to support Repeaters. That's what the concept of relations is for. The column would list the page ids of the repeater pages and the relations would hold the data of those pages (using regular RockFinder2 syntax $repeater->addColumns(['foo', 'bar'])).

If you need further help you can PM me.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild. 
      EDIT: You can now install it directly from the Modules directory: http://modules.processwire.com/modules/inputfield-float-range/
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Optional step value (Read more) Optional manual override of the selected value (will still adhere to the rules above) Configurable rounding of manually entered values (floor, round, ceil, disable) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant  
      Changelog
      005 (current version)
      - Fix bug where the Inputfield would not work properly within repeaters / repeater matrices
      004
      - Make rounding of manually entered values configurable (floor, round, ceil or disable)
      - Fix small JS bug when the value-display field was not displayed
      - Update README
      003
      - Code cleanup, add some ModuleInfo data & LICENSE
      - Submit to PW Modules directory (http://modules.processwire.com/modules/inputfield-float-range/)
      002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional
      001
      - Initial release
       
      Thanks!
       
       
    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
×
×
  • Create New...