Jump to content

$page->get(selector)


Kurbel
 Share

Recommended Posts

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...