jacmaes Posted September 25, 2012 Posted September 25, 2012 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.
nik Posted September 25, 2012 Posted September 25, 2012 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"); 8
jacmaes Posted September 25, 2012 Author Posted September 25, 2012 Thanks, Nik! I wasn't sure on the syntax. As usual, it's easier than anticipated.
mike77 Posted April 9, 2013 Posted April 9, 2013 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?
DaveP Posted April 9, 2013 Posted April 9, 2013 $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. 1
ryan Posted April 11, 2013 Posted April 11, 2013 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. 1 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now