Jump to content

get search result pages parents(advanced search)


leoric
 Share

Recommended Posts

this topic is unclear.

you can go to 3 and 7  floor , thank you.

i have a query result

$matches = $pages->find("title|summary|%=$q,template=_page_show,limit=12"); 

and i have a demand: find these result pages parent, then i could second search by page's parent(through click parent link and urlSegment)

it's means:

page tree:

        category A

                some pages..

        category B

                some pages..

        category C

                some pages..

        category D

                some pages..

search result:

all categories    category A  category B .....(if the category have search result)

some pages from search..

some pages from search..

some pages from search..

the default search result is all categories

$matches = $pages->find("title|summary|%=$q,template=_page_show,limit=12"); 

when i click category A, we could get category id by urlSegment do this query 

$matches = $pages->find("title|summary|%=$q,parent_id=$parent_id,template=_page_show,limit=12"); 

ui example:

all categories    category A  category B .....

some pages from search..(category A's Child)

some pages from search..(category A's Child)

some pages from search..(category A's Child)

...

now my question is  how to get all search result pages parents?  :(

is there anyone have solution? thank you.

Link to comment
Share on other sites

I read your question three times and still don't understand it, might be that someone else will read it more clearly and will be able to help you, but in case it's not just me having trouble with it, can you give some concrete examples of what you want to achieve?

  • Like 1
Link to comment
Share on other sites

I read your question three times and still don't understand it, might be that someone else will read it more clearly and will be able to help you, but in case it's not just me having trouble with it, can you give some concrete examples of what you want to achieve?

diogo , i am so sorry,my english is not good.  

i want to do this:

here is  some goods in my database(such as clothes):

(default search result) when i input a keyword like "Shirts",we will get all the results of the search criteria (categories:men's shirts,women's shirts,boy's chirts...etc..)

and now,i want to add a navigation bar on the top of search result for better filter goods.

there are some categories in the navigation bar ( men's shirts, women's shirts......),when i click men's shirts then we can get all men's shirts in the result.

is this more clear?

Link to comment
Share on other sites

Hey leoric,

take a look at this post, where the kind Macrura gave me (and us all ;)) some insights on how to filter a form's results based on different criterias.

It should point you out on what you are trying to achieve.

Let us know!

  • Like 2
Link to comment
Share on other sites

leoric,

I think we are all struggling to know exactly what you mean without knowing your page structure fully. In your first post you say to want to get the page's parent from the search results. The problem is that your results may find pages with different parents. The only way to get the parent is to do that on one page. Perhaps you need to rethink how your search works. Would it perhaps be better if the initial search term actually only looked at the category field for each page?

Another possibility would be do have a multiple option search like the skyscrapers demo (as noted above).

There are lots of options, but perhaps if you can detail out your site structure a little better, using actual content examples, like the shirts idea, we'll be better able to help.

Link to comment
Share on other sites

hi,everybody:

I solved the problem.

its my fault,i cant describe the question clearly. but the forum is very helpful,at last i found the solution in forum.

here is my test code:

$q='keyword';
$matches = $pages->find("title|summary|%=$q,template=_page_show");
$uniqueResults = array(); 
foreach($matches as $child)
{
	//echo $child->title.'<br>';
        //get the result page's parents
	$uniqueResults[$child->parent->title]=$child->parent;
}

foreach($uniqueResults as $r)
{
	echo '<b><a href="'.$r->url.'">'.$r->title.'</a></b><br>';
}

this post is helpful to me.

http://processwire.com/talk/topic/2038-distinct-selector-in-processwire/?p=19058

thank you all!

  • Like 2
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...