We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23128
    • 3 Posts
    Hi all.

    Have successfully implemented AdvSearch in a new site...but need to modify the result 'extracts' to remove some unwanted html markup that exists within fields in the DB (and can't be filtered out prior to search). Just wondered if anyone had any documentation covering 'PostHook' capabilities...and how to develop it?

    There is mention that PostHook "to be completed" in coroico's documentation (http://www.revo.wangba.fr/assets/files/advsearch/advsearchHook120_v1.0.pdf) - but no other details/examples/docs that I can find anywhere...including the MODX forums.

    Any help with additional information on PostHook would be much appreciated.

    Many thanks.

    PS: coroico, if you're out there...amazing work in AdvSearch! smiley
      • 5811
      • 1,717 Posts
      The postHook parameter is a name of snippet.
      The postHookTpls parameter is a csv list of tokens. This could be a csv list of chunk names used inside the postHook snippet to modify the presentation of results.

      In this example the advSearch snippet call is:
      [[!AdvSearch? 
        &pagingType=`0`
        &fields=`pagetitle,longtitle,menutitle`
        &queryHook=`PlanningQHook`  
        &container=`planningTableaux`
        &tpl=`planningTableau` 
        &postHook=`PlanningPHook` 
        &postHookTpls=`planningEntete,planningSalle,planningLigne,planningSession,planningSessionVide` 
        &withAjax=`1` 
        &ids=`[[!GetIds? &ids=`c24`]]` 
        &perPage=`7` 
        &withTVs=`jour,discipline,professeur,niveau,public` 
        &includeTVs=`salle,horaire`
      ]]


      In this example, the web user select one or several days of the week, the name of a professor, the type of danse, the level and the public type. Then the planning is displayed.
      Results are not displayed as a list of results but as a table per day of the week with the name of room as row.
      The filtering is done by using the queryHook. The displaying of results has been done by using the postHook.

      Inside the posthook snippet you can get the results by:
      $searchResults = $advsearch->searchResults;
      $results = $searchResults->results;
      $nbr = count($results);

      Then you could set up the results you want and then provide these results to AdvSearch by:
      $searchResults->results = $newres;
      $searchResults->resultsCount = count($newres);

      and you could modify the fields names by:
      $searchResults->mainFields = array('jour','planningHeader','planningBody');
      
      $hook->updateResults($searchResults);

      And use these new fields inside each result. In the above example, I have one result per day. [ed. note: coroico last edited this post 14 years ago.]
        • 23128
        • 3 Posts
        Thanks Coroico - this'll really help. Much appreciated.