I have been researching for a couple days now and I cannot seem to understand how to accomplish what I need. My Knowledge on Snippet development is limited. I have determined I need to use
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;