[[!AdvSearch? &ids=`[[!GetIds? &ids=`c50`]]` &containerTpl=`myAdvSearchResults` &tpl=`myAdvSearchResult` &withTVs=`img_main, price, size_w, size_h, size_d, century` &thumbWidth=`400` &thumbHeight=`400` &bgColor=`f1ebd8` &queryHook=`qhFilter` &init=`all` &perPage=`50` &debug=`1`]]
<?php $andConditions = array(); $andConditions['tv.price:>='] = 'minPrice:request:none'; $andConditions['tv.price:<='] = 'maxPrice:request:none'; if (!empty($andConditions)) { $qhDeclaration = array( 'qhVersion' => '1.3', 'andConditions' => $andConditions ); $hook->setQueryHook($qhDeclaration); } return true;
<?php $modx->setDebug(true); $main = array( 'tablePrefix' => 'modx_', 'package' => 'tagger', 'packagePath' => '{core_path}components/tagger/model/', 'class' => 'TaggerTagResource', 'fields' => 'resource, tag', 'withFields' => 'resource, tag', # TAGGER COLUMNS ); # STILL KEEPING THE PRICE SEARCH $andConditions = array(); $andConditions['tv.price:>='] = 'minPrice:request:none'; $andConditions['tv.price:<='] = 'maxPrice:request:none'; # Ignore for now, will be used when attribute option search is finally fixed $attributes = array(); foreach($_REQUEST as $key => $value){ $exp_key = explode('-', $key); if($exp_key[0] == 'attr'){ $attributes[$key] = $value; } } # Just debugging the attributes expansion, ignore this $modx->log(modX::LOG_LEVEL_DEBUG, json_encode($attributes)); # THIS TAG ID (OPTION) EXISTS, MANUAL QUERY FOR DEBUGGING PURPOSES $andConditions = array( 'TaggerTagResource.tag:=' => '1' ); if (!empty($andConditions)) { $qhDeclaration = array( 'qhVersion' => '1.3', 'main' => $main, 'andConditions' => $andConditions ); $hook->setQueryHook($qhDeclaration); } $modx->setDebug(false); return true;
This question has been answered by agilburg. See the first response.
<?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;