AdvSearch with query in results using queryHook


I am using AdvSearch to perform a search in multiple TVs. It works great, but in the results, I can’t get the query terms to show up. I have tried inserting the [[+query]] (or even [[+advsearch.query]]) placeholder, but nothing shows up. I noticed that if I use the default search form, the query string does show up in the search results page. I just can’t seem to get it to show up with my own custom form that searches in my TVs.

Any assistance would be much appreciated.

1 Like

Annoyingly I think the placeholders were given a new prefix in v2 of advsearch but from what I remember this wasn’t updated in all of the chunks, though it looks like you’ve already tried adding the prefix too. Do you have a custom prefix set with &asId in your call?If not try adding this:


If no luck then you can always force the placeholder value with something like this below in your hook, but you’ll need to find a way of capturing the query and setting the input if this doesn’t work - i had a quick look in the documentation but couldn’t see that but have a look through the code:

$modx->setPlaceholder('query', $input);

Thanks for the reply lkfranklin. I tried adding &asId=`` to the call, but no luck. Not super a very experienced coder, but will see what I can do with adjusting the hook. Any other assistance would be appreciated!

Are we talking about AvdSearch v2?
By default AdvSearch does not search in custom TVs. To make sure they are searched and show up in the results list include the name of your custom TV in the &withTVs property, and also in the &showExtract property. But note the &showExtract property must start with a number, e.g. 5:content,pagetitle,myFirstTV,mySecondTV where 5 is the number of extract you’d like to show, and you also need to include the full list of Resource attributes AND the TVs to show the extracts from.
So all together:
[[AdvSearch? ... &withTVs=`myFirstTV,mySecondTV` &showExtract=`5:content,pagetitle,myFirstTV,mySecondTV` ... ]]