<![CDATA[ Filter Results using AdvSearch and Tagger with Queryhooks - MODX Community Forums]]> https://forums.modx.com/thread/?thread=104691 <![CDATA[Filter Results using AdvSearch and Tagger with Queryhooks]]> https://forums.modx.com/thread/104691/filter-results-using-advsearch-and-tagger-with-queryhooks#dis-post-563096 AdvSearch with QueryHooks. But I am lost where to start. Never used AdvSearch only SimpleSearch.

Tagger is setup with 3 different tagger groups [Type, Service L1, Service L2] to be used on my sites resources (blogs, news, articles) pages.

I will have a resources.html page that will show ALL available resources under Resources [19]. Each resource will be tagged appropriately in the Template Variable using Tagger. I will show available tags under each group on the side menu (sort-of a search by filtering menu) and need to Filter the results on the page. This will occur either by submitting a button to "Apply Filters" or it will happen "Live" as tags are selected. The Submit button is what I need working, but having it live filter would be ideal. Any guidance on where to start would be appreciated.

I have some code to reference:
[Page]
[[!AdvSearchForm? &tpl=`AdvanceSearchForm_tpl`]]
<hr>
<h2>Results</h2>
<p>[[!AdvSearch? &parents=`19`&queryHook=`qhFilter`]]


[AdvanceSearchForm_tpl]
<form class="advsea-search-form" action="[[~[[+landing]]]]" method="[[+method]]">
  <fieldset>
    <input type="hidden" name="id" value="[[+landing]]" />
    <input type="hidden" name="asId" value="[[+asId]]" />

	<div class="group1">
	  <label>Type</label>
	  <select id="group1" name="group1">
		<option value="" selected="selected">-</option>
		[[TaggerGetTags? &ids=`[[!GetIds? &ids=`c19`]]` &groups=`1` &showUnused=`0` &rowTpl=`@INLINE <option value="[[+tag]]">[[+tag]]</option>`]]
	  </select>
	</div>
	
	<div class="group2">
	  <label>Service L1</label>
	  <select id="group2" name="group2">
	  	<option value="" selected="selected">-</option>
		[[TaggerGetTags? &ids=`[[!GetIds? &ids=`c19`]]` &groups=`2` &showUnused=`0` &rowTpl=`@INLINE <option value="[[+tag]]">[[+tag]]</option>`]]
	  </select>
	</div>
	
	<div class="group3">
	  <label>Service L2</label>
	  <select id="group3" name="group3">
	  	<option value="" selected="selected">-</option>
		[[TaggerGetTags? &ids=`[[!GetIds? &ids=`c19`]]` &groups=`3` &showUnused=`0` &rowTpl=`@INLINE <option value="[[+tag]]">[[+tag]]</option>`]]
	  </select>
	</div>
	
    <input type="submit" name="sub" value="[[%advsearch.search? &namespace=`advsearch` &topic=`default`]]" />
  </fieldset>
</form>
[[+resultsWindow]]


[qhFilter]
<?php
# Main for MODX
$main = array(
    'package' => 'modx',
    'packagePath' => '{core_path}model/',
    'class' => 'modResource',                         
    'fields' => 'id',                        
    'withFields' => 'id',                    
    'sortby' => 'TaggerTagResource.tag DESC',
    'tablePrefix' => 'modx_'
);
 
# Join with Tagger table
$joined = array(
    array(
        'package' => 'tagger',        
        'packagePath' => '{core_path}components/tagger/model/', 
        'class' => 'TaggerTagResource',
        'withFields' => 'resource, tag',
        'fields' => 'resource, tag',
        # On the resource ID
        'joinCriteria' => 'modResource.id = TaggerTagResource.resource',
        'tablePrefix' => 'modx_'
    )
);
 
$andConditions = array(
    # One tag/option
    'TaggerTagResource.tag:=' => '2',
    # Another tag/option
    'TaggerTagResource.tag:=' => '4'
);
 
# set the query hook declaration
$qhDeclaration = array(
    'qhVersion' => '1.3',
    'main' => $main,
    'joined' => $joined,
    'andConditions' => $andConditions
); 
$hook->setQueryHook($qhDeclaration);
 
return true;
]]>
smorris Dec 05, 2018, 12:18 AM https://forums.modx.com/thread/104691/filter-results-using-advsearch-and-tagger-with-queryhooks#dis-post-563096
<![CDATA[Re: Filter Results using AdvSearch and Tagger with Queryhooks]]> https://forums.modx.com/thread/104691/filter-results-using-advsearch-and-tagger-with-queryhooks#dis-post-563191 Form with debug. A few errors listed
[2018-12-10 17:54:42] (DEBUG IN ADVSEARCH::LOADDEFAULTCONFIGS @ /PAAS/C0231/WWW/CORE/COMPONENTS/ADVSEARCH/MODEL/ADVSEARCH/ADVSEARCH.CLASS.PHP : 113)

[AdvSearch] System environment: Array
(
    [MODx version] => 2.6.5-pl
    [Php version] => 7.1.25
    [MySql version] => 5.6.38-83.0
    [AdvSearch version] => 2.0.0 beta2
)
[2018-12-10 17:54:42] (DEBUG IN ADVSEARCH::LOADDEFAULTCONFIGS @ /PAAS/C0231/WWW/CORE/COMPONENTS/ADVSEARCH/MODEL/ADVSEARCH/ADVSEARCH.CLASS.PHP : 114)

[AdvSearch] Config parameters before checking: Array
(
    [corePath] => /paas/c0231/www/core/components/advsearch/
    [assetsUrl] => assets/components/advsearch/
    [chunksPath] => /paas/c0231/www/core/components/advsearch/elements/chunks/
    [modelPath] => /paas/c0231/www/core/components/advsearch/model/
    [addCss] => 1
    [addJQuery] => 1
    [addJs] => 1
    [ajaxResultsId] => 0
    [asId] => as0
    [clearDefault] => 1
    [debug] => 1
    [help] => 1
    [jsSearchForm] => assets/components/advsearch/js/advsearchform.min.js
    [jsJQuery] => assets/components/advsearch/js/jquery-1.7.1.min.js
    [landing] => 0
    [liveSearch] => 0
    [method] => GET
    [opacity] => 1
    [searchIndex] => search
    [toPlaceholder] => 
    [tpl] => AdvanceSearchForm_tpl
    [urlScheme] => -1
    [withAjax] => 0
    [charset] => UTF-8
)
[2018-12-10 17:54:42] (ERROR @ /PAAS/C0231/WWW/CORE/MODEL/MODX/MODX.CLASS.PHP : 990)

`` is not a valid integer and may not be passed to makeUrl()
[2018-12-10 17:54:42] (ERROR IN RESOURCE 19 @ /PAAS/C0231/WWW/CORE/MODEL/MODX/MODPARSER.CLASS.PHP : 1372)

Bad link tag `` encountered
[2018-12-10 17:54:42] (ERROR @ /PAAS/C0231/WWW/CORE/MODEL/MODX/MODPARSER.CLASS.PHP : 540)

Could not find snippet with name GetIds.
[2018-12-10 17:54:42] (ERROR @ /PAAS/C0231/WWW/CORE/MODEL/MODX/MODPARSER.CLASS.PHP : 540)

Could not find snippet with name GetIds.
[2018-12-10 17:54:42] (ERROR @ /PAAS/C0231/WWW/CORE/MODEL/MODX/MODPARSER.CLASS.PHP : 540)

Could not find snippet with name GetIds.
[2018-12-10 17:54:42] (DEBUG IN ADVSEARCHFORM::OUTPUT @ /PAAS/C0231/WWW/CORE/COMPONENTS/ADVSEARCH/MODEL/ADVSEARCH/ADVSEARCHFORM.CLASS.PHP : 315)

[AdvSearch] Elapsed time:0.0315s



Results with debug:
[2018-12-10 17:54:42] (WARN @ /PAAS/C0231/WWW/CORE/CACHE/INCLUDES/ELEMENTS/MODSNIPPET/155.INCLUDE.CACHE.PHP : 31)

PHP notice: Undefined index: asId
[2018-12-10 17:54:42] (WARN @ /PAAS/C0231/WWW/CORE/COMPONENTS/ADVSEARCH/MODEL/ADVSEARCH/ADVSEARCH.CLASS.PHP : 58)

PHP notice: Undefined index: withAjax
[2018-12-10 17:54:42] (DEBUG IN ADVSEARCH::LOADDEFAULTCONFIGS @ /PAAS/C0231/WWW/CORE/COMPONENTS/ADVSEARCH/MODEL/ADVSEARCH/ADVSEARCH.CLASS.PHP : 113)

[AdvSearch] System environment: Array
(
    [MODx version] => 2.6.5-pl
    [Php version] => 7.1.25
    [MySql version] => 5.6.38-83.0
    [AdvSearch version] => 2.0.0 beta2
)
[2018-12-10 17:54:42] (DEBUG IN ADVSEARCH::LOADDEFAULTCONFIGS @ /PAAS/C0231/WWW/CORE/COMPONENTS/ADVSEARCH/MODEL/ADVSEARCH/ADVSEARCH.CLASS.PHP : 114)

[AdvSearch] Config parameters before checking: Array
(
    [corePath] => /paas/c0231/www/core/components/advsearch/
    [assetsUrl] => assets/components/advsearch/
    [chunksPath] => /paas/c0231/www/core/components/advsearch/elements/chunks/
    [modelPath] => /paas/c0231/www/core/components/advsearch/model/
    [parents] => 19
    [queryHook] => qhFilter
    [debug] => 1
    [contexts] => web
    [fields] => pagetitle,longtitle,alias,description,introtext,content
    [charset] => UTF-8
)
]]>
smorris Dec 11, 2018, 12:02 AM https://forums.modx.com/thread/104691/filter-results-using-advsearch-and-tagger-with-queryhooks#dis-post-563191
<![CDATA[Re: Filter Results using AdvSearch and Tagger with Queryhooks]]> https://forums.modx.com/thread/104691/filter-results-using-advsearch-and-tagger-with-queryhooks#dis-post-563172
&debug=`1`
in the snippet's call, and identify the problem from error log.]]>
goldsky Dec 10, 2018, 04:06 AM https://forums.modx.com/thread/104691/filter-results-using-advsearch-and-tagger-with-queryhooks#dis-post-563172