Recently Browsing 0 members
No registered users viewing this page.
I want to allow full text search on my site. There is a very nice solution that comes right out of the box:
$selector = "title|body~=$q, limit=50"; This works, but to make it even better I would want to give higher weight to pages where the search term occurs in the title, than if it just occurs in the body. After all, a page with the title "Wine from France" is probably the best match for the search "france wine". How do I accomplish this in ProcessWire?
I can see three possible paths, but I am not very fond of any of them:
Do a direct SQL query, circumventing the API, along these lines. But I would prefer to abstract away the database layout if at all possible. Use something like ElasticSearch, but to be honest that would be to complicated to set up and maintain in the long run. Make multiple lookups, first for matches in the title, then for matches in the body, and merge and sort in PHP. My suspicion is that this would get complicated quite quickly. For instance, how do you deal with a page that has two of the three search terms in the title and the third in the body? Is there a magic option four I should look into? Or are any of the above options better than the others? Any input is welcome!
By Roberts R
I have simple page structure:
category subcategory simple-product simple-product simple-product simple-product subcategory .... category2 so Im at category page and running
$pages->find("template=simple-product, has_parent=$page, limit=8"); and it returns 0 pages
but this returns 4 pages
$pages->find("template=simple-product, has_parent=$page"); Can someone explain why limit does not work here?
So I did some tests and it seems that any limit=n where n is >= actual page count that is possible ... selector return 0 results.
ProcessWire added the numReferences property in 3.0.107, which returns the count of all pages having a reference to the page object. However, apparently it's not possible to use this property inside a selector. I'm trying to find all pages that are referenced at least once:
$pages->find('template=service, numReferences>0'); This throws an error: "Field does not exist: numReferences".
Is there another way to filter by the number of references? Of course, I could manually filter the results of the find query, but that feels overly complicated. Ideally, I would also like to filter the number of references from a specific field; that is, find all pages that are referenced at least once in one specific page reference field.
Is there a way to do this? I guess supporting numReferences in selectors would be a feature request - if so, is it feasible?
Hello, I have a Page Reference by template radio button field to promote a certain page (only two options), but I'd like to target the page that isn't selected. This would be used dynamically throughout the site.
Does anyone know how I could accomplish this? Would I use something like remove() or not()?
I have two Page Reference fields: Category and Subcategory. Category is parent of Subcategory, and can have 0 to n Subcategories. Fields are selected by dropdown selection.
I'm trying to achieve following logic:
1. Select Category (obviously works)
2. Change Subcategory options based on selected Category (this works)
3. Hide the Subcategory field if Category has no Subcategories (to prevent weird dropdown with nothing to select)
I have tried to investigate two possible alternatives to achieve step 3:
A) Make dynamic condition into Subcategory selection's "Only visible if..." field
B) Make a hook that fires when Category changes, then hides Subcategory field if Category has no children
So far I haven't been successful in either. Conditions I've tried always lead to hidden field, and I haven't been able to find set up a hook that fires on field change.
So here's the question (finally): Is there a way to alter field visibility in API, for example in ready.php or inside a hook? In API I could loop through categories, find the ones that have children and then make a selector based on their IDs.