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

    After a changing and restfull break, partially far away from any broadband connexion, yes I could help you smiley

    Could you post the content of your configuration file and your AS snippet calls. Thks.
      • 18367
      • 834 Posts
      Coroico,

      here’s the call

      <p>[!AjaxSearch? &language=`english-utf8`&whereSearch=`products,stocks,providers` &documents=`1,2,3,4,5,6,7,8,9,10,11,12` &filter=`name,iphone,10|pvd_name,Nokia,10` &order=`name`&extract=`99:description` &config=`owntables-2` &searchWordList=`owntables-2WordList` &stripOutput=`saveHtml` &tplLayout=`@FILE:assets/snippets/ajaxSearch/templates/optionMultipleList/layout.tpl.html` &tplAjaxResult=`@FILE:assets/snippets/AjaxSearch/templates/owntables-2AjaxResult.tpl.html`!]</p><p><br></p>


      It’s actually been awhile since I set this up, but I pretty much tried to follow the tute on your site to the letter.

      I even recreated the data in my db..

      Here’s the config file. I don’t think I changed anything.

      <?php
      
      function saveHtml($results){ 
      
        // replace line Breaking by space
        $results = stripLineBreaking($results);
        // strip javascript tags
        $results = stripJscripts($results);
        
        return $results;
      }
      
      function owntablesWordList(){ 
      
        $list = "GPS,phone,Nokia,HTC,i-mate,Palm,Iphone,Blackberry";
        return $list;
      }
      
      function products(& $main,& $joined, $listIDs){
      
        $main = array(
            'tb_name' => "ext_products",
            'tb_alias' => 'pdt',
            'id' => 'id',
            'searcheable' => array('name','image','description'),
            'date' =>array(),
            'filters' => array(),
            'jfilters'  => array()
          );
          
        $main['filters'][]= array(
            'field' => 'available',
            'oper' => '=',
            'value' => '1' 
        );
        
        $main['filters'][]= array(
            'field' => 'id',
            'oper' => 'in',
            'value' => $listIDs
        );
          
        $joined = NULL;
      }
      
      function stocks(& $main,& $joined, $listIDs){
      
        $main = NULL;
                
        $joined = array(
              'tb_name' => "ext_stocks",
              'tb_alias' => 'stk',
              'main' => 'id',
              'join' => 'product',
              'concat' => array('name'),
              'concat_alias' => array('stk_name'),
              'concat_separator' => ', ',
              'filters' => array()
          );
        $joined['filters'][]= array(
              'field' => 'nb',
              'oper' => '>',
              'value' => '0' 
        );
      }
      
      function providers(& $main,& $joined, $listIDs){
      
        $main = NULL;
                
        $joined = array(
              'tb_name' => "ext_providers",
              'tb_alias' => 'pvd',
              'main' => 'provider',
              'join' => 'id',
              'concat' => array('name','web'),
              'concat_alias' => array('pvd_name','pvd_web'),
              'concat_separator' => ', ',
              'filters' => array()
          );
      }
      
      ?>


      OK, It’s late down here, time to sign off till the morning.
        Content Creator and Copywriter
        • 5811
        • 1,717 Posts
        The mistake come from the name of the searchWordList parameter ...

        In the call you have &searchWordList=`owntables-2WordList` and in the configuration file you have :
        function owntablesWordList(){ 
        
          $list = "GPS,phone,Nokia,HTC,i-mate,Palm,Iphone,Blackberry";
          return $list;
        }


        The correct snippet call should be with : &searchWordList=`owntablesWordList`. The mistake comes from my tutorial. It’s correct on my demo site not in the tutorial withYourOwnTbles_tutorial_2_ajax.txt file.
          • 18367
          • 834 Posts
          OK,

          it works on my desktop server but I also get an error message
          Warning: mb_strrpos() [function.mb-strrpos]: Empty haystack in C:\wamp\www\acwa\assets\snippets\ajaxSearch\classes\search.class.inc.php on line 802


          Otherwise the results show up fine.

          Also, works absolutely fine on my live server, which is strange as it’s a copy of my local one.



            Content Creator and Copywriter
            • 5811
            • 1,717 Posts
            This warning comes is due to a call to the mb_strrpos php function with an empty text.
            This warning occurs with the statement
             $extracts[$i]['left'] = (int) $mbStrrpos($mbSubstr($text,0,$extracts[$i]['left']),' ');
            when I tried to find the closest white space on the left of a word found into a text. If the text starts with the searchstring, then the text variable is empty.

            Thanks for this feed back. I will add in the next release a test before to avoid this empty test and this warning. [EDIT: registered as FS#47 in the AS bug tracker]
            Have you tried the same search (same searchterm and same text in documents) ? This could explain the difference between your local and live server
              • 32645
              • 377 Posts
              The documentation on http://www.modx.wangba.fr/index.php?id=180 and http://www.modx.wangba.fr/assets/snippets/ajaxSearch180/documentation/ajaxSearch_example_1.txt is not very good at all.

              1. In "Define where to do the search" it mentions that you need a configuration file, but where does it go? Why does it look like a snippet for?
              2. There is no snippet call until near the bottom of the page.

              It should at least show the basics first and build up, not just show the final snippet call and say "here you go" without explanation.

              All I want to know is, how to make Ajaxsearch look at another table ... and viola, do the search on specific fields
                • 32645
                • 377 Posts
                Is it possible to force AjaxSearch to take a SQL command? I’m wanting to use AJAX search to search my results of holidays.
                  • 5811
                  • 1,717 Posts
                  @worchyld

                  You are right the documentation is not very good and could be improved.
                  As soon as I have enought time, I will improved the demo page.
                    • 5811
                    • 1,717 Posts
                    @worchyld

                    Give me your mysql table definition (holydays ?) and the possible link with modx tables. And i will try to explain you how implement this search.
                      • 32645
                      • 377 Posts
                      Quote from: coroico at Feb 25, 2009, 01:11 PM

                      @worchyld

                      Give me your mysql table definition (holydays ?) and the possible link with modx tables. And i will try to explain you how implement this search.

                      I’ve pm-ed you with my custom table I want to be powered by AjaxSearch.

                      The custom table is over 40 fields long, I don’t want all fields to be searchable, just a few of them would do.

                      If AjaxSearch can handle the search processing, this would solve a lot of problems for me!

                      Thanks.