We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22840
    • 1,572 Posts
    Hi All,

    Having major trouble trying to limit the results here.

    Basically I have category’s set out as follows:

    North of England
    -Cheshire
    --Crabwall Manor Hotel (this is a hotel )
    -Cumbria
    -Durham
    -Lancashire
    Heart of England
    -Derbyshire
    -Staffordshire
    --Another Hotel (this is a hotel )
    -West Midlands

    What I am trying to do is have a dropdown that lists the categories and have achieved this via ditto. however is someone searches by ( for example )Heart of england it is still displaying all hotels across all locations and its driving me mad.

    The start id for the call hase to be 4 because that is the locations page that has all other pages under it but I can’t seem to get it to only return the selected results for the area.

    Heres my call on the landing page:
    [!AjaxSearch? &ajaxSearch=`0` &AS_showForm=`0` &parents=`4` &depth=`3` &grabMax=`15` &order=`pagetitle` &tplResult=`tvphxResult` &tvPhx=`tv:displayTV`!]


    If I change the depth to 2 is shows nothing

    Any help would be great as this will be a main feature of the site.

    Thank you


      • 5811
      • 1,717 Posts
      Hi Paul,
      What I am trying to do is have a dropdown that lists the categories and have achieved this via ditto. however is someone searches by ( for example )Heart of england it is still displaying all hotels across all locations and its driving me mad.
      If I understand your request, you would like a dropdown menu with a list of location and when a location is selected, get the hotels of the location. Is it a correct understanding ?

      If No. Apologies, I don’t undertsand huh

      If yes, try to do as follow:
      1/ create a TV named location
      2/ for each document of a category initialize the location with the name of location. For instance "Heart of England"
      3/ use &searchWordList=`locationList` &tplLayout=`optionMultipleList` &whereSearch=`content:NULL|tv` &config=`location`

      Create a chunk optionMultipleList by copy/paste the template of templates/optionMultipleList/layout.inc.tpl

      By using content:NULL|tv you search only in the tv. content fields are avoid.

      4/ create a file configs/location.inc.php with:
      <?php
      
      if(!function_exists('locationList')) {
        function locationList($p){ 
      
          // get the location list from Dtto
          $params['parents'] =  1;        // set the root Id of your document tree
          $params['depth'] =  1;          
      
          $list = $modx->runSnippet('Ditto', $params);
          return $list;
      }
      
      ?>
      or if your document tree hasn’t a unique id as root
      <?php
      
      if(!function_exists('locationList')) {
        function locationList($p){ 
      
           // get the location list from Dtto
           $params['documents'] =  '1,15,25,76';        // set here the Id list of location container
      
           $list = modx->runSnippet('Ditto', $params);
           return $list;
      }
      
      ?>


      I not sure of the ditto parameters, but this seems like that.

      The nearest example on the demo site seems to be at : http://www.modx.wangba.fr/index.php?id=259.
        • 22840
        • 1,572 Posts
        Hi coroico,

        Thanks for the reply, will try it tomorrow when I get into work grin