Alex Rubinshtein Posted July 10, 2014 Share Posted July 10, 2014 Hi! I'm writing a search engine for an actors agency website. There's an age field and I want to be able to search pages by a range of ages. I've wrote this: $minAge = $input->get['minAge']; echo ($pages->find("age > $minAge")->id); and get an error. Link to comment Share on other sites More sharing options...
kongondo Posted July 10, 2014 Share Posted July 10, 2014 (edited) Hi Alex, Welcome to ProcessWire and the forums... Not sure what error you are getting but I am guessing the problem is the ->id part. A $pages->find will return and array of pages (i.e. there will be multiple ids); so, you only need $pages->find("age>$minAge"). You can then iterate through them. See examples here: http://processwire.com/api/variables/pages/ Secondly, nothing to do with your error, but you need to sanitize your input values first. In this case, you need to do at least this: $minAge = (int) $input->get['minAge']; The above are quick examples...you might need to sort out your double versus single quotes in the selector...I often forget which is which ...I might have missed something....others will correct if I did Edited July 10, 2014 by kongondo 2 Link to comment Share on other sites More sharing options...
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