Jump to content

Recommended Posts

Posted

In the "search.php" template that comes with the download of PW, this line allows you to search for "title", "body" and "sidebar" fields:

$matches = $pages->find("title|body|sidebar~=$q, limit=50");

But how do you search for content inside a repeater field?

Thanks.

Posted

It's possible to use <repeater-name>.<field-in-repeater> as a field name. For example:

$matches = $pages->find("title|my_repeater.my_field~=$q");
  • Like 8
  • 6 months later...
Posted

Is it possible to search for a certain file (using name of that file) added through File field in admin panel? Simply adding a name of the Field in search.php as is written above generates an error of course.

Can I perhaps retrive names of the files from the records stored in field_file table in DB put them into an array and then pass somehow into the $matches variable in search.php? Will it work with PW API?

Posted
$contracts = $page->files->find('description*=Contract');
$catlist = $page->files->get('description*=Cat List');

Are a couple of lines from an actual intranet app we use at work.

  • Like 1
Posted

You can match in either the filename, description, or tags via any of the DB-find functions too. 

$pages->find("files=myfile.jpg"); 
$pages->find("files%=myfile"); 
$pages->find("files.description*=some text"); 
$pages->find("files.tags%=mytag");  

One thing to note is that description and tags have fulltext indexes, but the actual filename doesn't. As a result, if you need to perform a partial match on filename, you can only use the "%=" operator. 

  • Like 1
  • Thanks 1

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
×
×
  • Create New...