We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7045
    • 225 Posts
    I will send you my email now, and I really appreciate it. I just looked over the demo briefly, damn that looks good.

    Thanks again
      • 7045
      • 225 Posts
      I just PM’d my email address to you.
        • 5811
        • 1,717 Posts
        I have added a demo with a faceted search inside a custom package. The package used is rather simple with two resources dvdProducts and dvdCategories. You could find the schema by clicking on the link custom package.
        Here dvdProducts is declared as main resource and dvdCategories as joined resource. To understand how does it work follow the link dvd2QHook. This snippet is called by advSearch when the query is set up (see the snippet call of the result page). The default modResource (and TVs)is here not taken into account.
          • 20178
          • 82 Posts
          Hi could this be used to search user data? or will it only search resources?

          thanks
            • 5811
            • 1,717 Posts

            What are you calling user data ? This possible, if your data are stored in a table in the same MySQL database as MODx.

            AdvSearch 1.0.0 RC2 is now available from the repository. And you can get more information by reading the chapters "main" and "joined" of the query hook documentation.
              • 20178
              • 82 Posts
              hi thanks for the quick response, yes the data is stored in the same database

              Basically - i want a site adminstrator to be able to search users extended field data.

              this is an example of a users extended field data;

              {"language1":"english","languagelevel1":["written","spoken"],"righttowork":"yes","gcse1":"Dutch","gcse1grade":"A*","gcse2":"Physics","gcse2grade":"C","gcse3":"Danish","gcse3grade":"B","gcse4":"Dutch","gcse4grade":"C"}


              i need to be able to search a number of different ways - search for string - and search via form - drop downs and checkboxes - so i can then extend upon this -
                • 5811
                • 1,717 Posts
                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.
                  • 20178
                  • 82 Posts
                  many thanks, this could be great i need to have a play with this! will post my outcomes and am sure i will be back looking for help again!