Kurbel Posted June 30, 2014 Share Posted June 30, 2014 Hi Guys, I'm building a custom search function, that needs to loop through certain pages (selected by template) and check fields for a string. I thought this would be easy with $p->get("title|headline|copy|sidebar~=$q"); (where $p is a page object and $q a query string). Somehow this always returns true. What am I missing here? Cheers, Kurbel Link to comment Share on other sites More sharing options...
marcus Posted June 30, 2014 Share Posted June 30, 2014 Try $p->find() instead. 1 Link to comment Share on other sites More sharing options...
Soma Posted June 30, 2014 Share Posted June 30, 2014 This get() always returns a page or a null page ( if nothing found) Link to comment Share on other sites More sharing options...
SiNNuT Posted June 30, 2014 Share Posted June 30, 2014 Wouldn't it be better to do this with a $pages->find()? $pages->find("template=mytemplate, title|name|headline=$q"); 1 Link to comment Share on other sites More sharing options...
Kurbel Posted June 30, 2014 Author Share Posted June 30, 2014 Hi Guys, I think I might have circumvented the whole issue. However, in case somebody runs into something like this or somebody has a better idea how to go about it, here's what's the situation: - I have content pages, that have content, which should be searchable. - I also have widgets that get rendered in the context of content pages (basic echo $widget->render()) and should also be searchable. However in case a widget matches the query I need to return the page or pages that do reference this widget. Originally I thought I just loop through all the pages, one by one. If the original page matches it get's thrown into an array for further reference, if not the loop continues through all the referenced widgets. This has the drawback, that a) I never got it to run and b) it probably won't perform as well, since the widgets will get parsed more than once if they are referenced on more than one page. The new Idea is to first search through all pages that have a page template via $pages->find() and then do the same with all widgets. For every widget that is found find the pages where it's referenced and throw those into the $matches array. Last step: Remove the duplicates. Cheers, Kurbel 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