How to pass search query terms to nested content


(Marg C) #1

Hi,

 

I'm trying to modify one of our existing search pages to display the nested results of a secondary search page which looks for images (a bit like a Google results page I suppose, where it shows a few images based on your current search, and then you can choose to go and look at more image results). Ideally there'd be, say, 20 results per page for the standard search, but only the first 5 or 10 image results would show with a link to more.

 

There are a few reasons we want it to work this way, as opposed to just adding images as an asset type to the existing search:

  1. The existing search is restricted to the one site, but we want to pull images from multiple sites.
  2. There will be potentially thousands of image results for some terms so we don't want them interspersed with the standard page results.
  3. We don't want to force people to wait for the results of a combined page and image search if they're just after pages.

So the existing search is just an ordinary Matrix search page set up to look for standard pages within one site (this is the current, live search page: http://classroom.antarctica.gov.au/search).

 

Within the results page layout of this Search page, I've now nested the secondary image search page (it's under construction, so you can't see it, sorry).

 

The image search page is set up to do stored searches, using a GET variable which is query.

 

In the nested content properties (see image), I've added a variable called query, to match the stored search. When I use a fixed term (such as penguins, as you can see in the image), it works beautifully, nesting the 'penguins' image results within the results page of the main search.

 

[attachment=700:image-search.gif]

 

However, what I need to do is somehow pass the term the user has entered on the main search page into the image search. So if they visit the search page linked above and type in emperor penguin, I want that term to be fed through to the nested content query variable so that it's used by the image search as well.

 

Therefore I've tried, without any success, putting the search term keyword normally used on the results page (in this case it's %keywords_query_terms%) into the Variable Value field in the nested content's properties (where I currently have 'penguins').

 

I've tried:

  • %keyword_query_terms%
  • %list_current_keyword_query_terms%
  • %nested_keyword_query_terms%
  • %globals_keyword_query_terms%

None of these work. The first three just cause a search for the actual keyword (i.e. 'keyword_query_terms'). The 'globals' one brings back a blank (which implies that it's at least being resolved, but it's somehow losing its value before it gets passed).

 

If I change 'Disable keyword replacements' on the Image search's details screen to 'No' then they all come back blank.

 

Am I missing something or is this destined to fail? I'm open to other suggestions of ways to make this work.

 

Thanks! image-search.gif (20 KB)


(Aleks Bochniak) #2

Have you tried %globals_get_query% ?


(Marg C) #3

Hi Aleks,

 

Thanks. No, I hadn't tried that because I wasn't aware of its existence ... however, I have now and it doesn't work.

 

The problem is, I'm trying to tell the nested image search what the value of my variable 'query' should be.  I want to tell it to be what the person has typed into the main search query - i.e. the value of %keyword_query_terms%, as used on the results page layout.


(Marg C) #4

Ok, hopefully this image will help explain things a bit more clearly. This is the results page layout of the main search page. I want to tell the image search that the value of its 'query' variable should be whatever the user has entered into the main search (i.e. keyword_query_terms). As explained above, I have tried a few different variations on this keyword but none of them have worked. Is there a way?

 

[attachment=701:image-search-keywords.gif] image-search-keywords.gif (31 KB)


(Joel Porgand) #5

try %globals_get_queries_keyword_query%


(Marg C) #6

OMG that worked, thank you so much JP! :D


(Bart Banda) #7

%nested_get_query% should also work in recent versions of Matrix.