If you have already a package named for instance ’language’ with a class ’userLanguage’, you could use AdvSearch with a queryHook (named for instance ’languageQHook’ ) like this:
<?php
$main = array(
'package' => 'modx',
'packagePath' => '{core_path}model/schema/',
'class' => 'modUser', // you use the modUser resource as main resource
'fields' => 'username', // displayed
'withFields' => 'username', // where we do the search
'sortby' => 'modUser.username DESC'
);
// add you language package as joined. The primary key id is supposed equal to the modUser id key
$joined = array(
array(
'package' => 'language',
'class' => 'userLanguage',
'packagePath' => '{core_path}components/language/model/',
'fields' => 'language1 , languagelevel1, righttowork, gcse1, gcse1grade, gcse2, gcse2grade, gcse3, gcse3grade, gcse4, gcse4grade',
'withFields' => 'language1 , languagelevel1, righttowork, gcse1, gcse1grade, gcse2, gcse2grade, gcse3, gcse3grade, gcse4, gcse4grade',
'joinCriteria' => 'modUser.id = userLanguage.id'
)
);
// set the query hook declaration
$qhDeclaration = array(
'qhVersion' => '1.1',
'main' => $main,
'joined' => $joined,
);
$hook->setQueryHook($qhDeclaration);
return true;
Then depending the form (named for instance ’languageSearchForm’), you could add in your queryHook the necessary andConditions you want.
(Keep care the REGEXP operator doesn’t work for field for custom package. Use preferrably ’=’ or LIKE)
Finally to get on the same page, the form and the results, add:
[[!AdvSearchForm? &tpl=`languageSearchForm`]]
[[!AdvSearch? &queryHook=`languageQHook` &tpl=`languageResult` ]]
Where langageResult is the template which manage the data displayed for each result.