I combined Tagger with AdvSearch using a hook, as explained by Adam Lundrigan (site is offline, I used google cache to look at his code).
This is the snippet:
<?php
$modxTablePrefix = 'modx_';
$taggerModelPath = '{core_path}components/tagger/model/';
$hook->setQueryHook(array(
'qhVersion' => '1.2',
'joined' => array(
array(
'package' => 'tagger',
'class' => 'TaggerTagResource',
'packagePath' => $taggerModelPath,
'withFields' => 'resource',
'tablePrefix' => $modxTablePrefix,
'joinCriteria' => 'TaggerTagResource.resource = modResource.id'
),
array(
'package' => 'tagger',
'class' => 'TaggerTag',
'packagePath' => $taggerModelPath,
'withFields' => 'tag',
'tablePrefix' => $modxTablePrefix,
'joinCriteria' => 'TaggerTag.id = TaggerTagResource.tag'
),
)
));
return true;
And this is the advSearch snippet call. It works, however I can't get fieldPotency to take the Tagger field. I tried this:
[[!AdvSearch?
&hideContainers=`0`
&minChars=`2`
&fields=`pagetitle,content,introtext`
&withFields=`pagetitle,content,introtext,description`
&highlightTag=`strong`
&searchIndex=`zoekterm`
&perPage=`10`
&engine=`mysql`
&pagingType=`1`
&pagingSeparator=``
&showExtract=`1:introtext,content`
&addCss=`0`
&addJs=`0`
&toPlaceholder=`searchresults`
&init=`all`
&offsetIndex=`start`
&queryHook=`searchTagger`
&fieldPotency=`pagetitle:100, tag:80, content:50, introtext:30, description:10`
&sortby=`score DESC`
]]
The problem is first of all I don't know how to reference the Tagger field (used 'tag', but not sure if that's correct) and second of all I don't know if it's possible to use a joined field in the fieldPotency field. For now, this example isn't working. The resource with a value in Tagger that is searched for IS found, but it's not on top of the list, as I would expect because of the fieldPotency.
Does anyone know if it's possible, and if so what I should do exactly?
Thanks a lot!
[ed. note: michelle84 last edited this post 9 years, 6 months ago.]