findBy() never work for me

Hi,

I am new on the forum. I use Kirby for my compagnie’s website the version 1 is online at urumqi.fr.
I make some modification for the next release and i want to use the function findBy(); but it was never functional for me.

I make a plugin who generate a caption with project’s information and a tag who return this caption.

In the first version of the site, i use findByURI(). Now i want to use a ‘code’ field to find the the correct $page record.

precedent code is ok but i want change the uri for better reading in the panel.

function projet($identifiant) {
    $projet = page('projects')->children()->findByURI($identifiant);
    return ($projet);
  }

This is the new function but it return a bool

  function project($identifiant) {

    $project = page('projects')->children()->findBy('code','*=', $identifiant);

    return ($project);
  }

If someone can explain to me why the function findBy() don’t work.

An exemple of record

Title: AC83012001 - Pharmacie porte d'azure

----

Code: AC83012001

----

Referenceexterne: false

and exemple of tag

(projet: AE83014009)

You can use use filterBy('code','*=', $identifiant) instead of findBy(), findBy() does not work with filtering operators like *= etc.; filterBy() returns a collection, while findBy() returns a single page.

I find a solution,
I have change ‘code’ by ‘identifiant’’ and now it is ok.

  function project($identifiant) {

    $project = page('projects')->children()->findBy('identifiant', $identifiant);

    return ($project);
  }