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
    following my question (Reply #291 on: Oct 30, 2007, 12:38 PM ») huh, I have updated the Ajaxsearch snippet to correct/improve some functionalities when the ajaxSearch mode is selected.

    I have built a 1.6.1 version from 1.6 version (delivered with Modx 0.9.6) with the followings corrections :

    - management of opacity. Correction of an Internet Explorer bug. (the ajax_output div is always visible even without results).

    I have added a opacity parameter to set the wished value to the ajax_output div (see the snippet code for more explanations). Not tested with the scriptaculous librairy

    - management of accented characters for search words. In UTF8 but also in ISO-8859-1 and any other character set

    Tested on UTF-8 and ISO-8859-1 web sites with Firefox 2.0 and IE 6.0

    Here are some demonstration web sites :
    UTF8 :
    Récits de voyage, enter "année" as search word.
    Sorry only in French.

    Colors of The Andes, enter "rubén" as search word.
    French, Spanish, English languages available.

    The php mbstring extension should be active on your server.
    The $database_connection_charset variable should be defined in the file /manager/includes/config.inc.php.

    Plugin code hasn’t changed. Only the snippet part of AjaxSearch should be reload.

    Code improvements are commented inside each updated files.

    Download the 1.6.1 version snippet code on the following post on the French modx forum at http://modxcms.com/forums/index.php/topic,19755.0.html

    I will propose these few updates to Kylej

    See the next post for the new version 1.6.2
      • 5811
      • 1,717 Posts
      Please find a new version of AjaxSearch. Version 1.6.2 based on version 1.6. This new version includes functionalities of the 1.6.1 version. Functionalities described on the previous post.

      This new version brings selection of document IDs where the search occurs. The new parameters are :

      &parents [comma-separated list of integers MODx document IDs] (optional)
      A list of parent-documents whose descendants you want searched to &depth depth when searching.
      All parent-documents by default

      &depth [int] (optional)
      Number of levels deep to go.
      Any number greater than or equal to 1. 25 levels by default. It could be enought smiley

      &documents [comma-separated list of integers MODx document IDs] (optional)
      A list of documents where to search

      Some examples :

      [!AjaxSearch!]
      search in all the documents

      [!AjaxSearch? &documents=`2,3,8,16`!]
      search in the documents 2,3,8,16 only

      [!AjaxSearch? &parents=`5,7`!]
      search in all the son-documents of father-documents 5 and 7

      [!AjaxSearch? &parents=`5,7` &depth=`2`!]
      search on 2 levels in the son-documents of father-documents 5 and 7

      I will propose this new version to Kylej too.

      Next step : i would like to add a ditto-like filter to avoid some documents.

      Param: filter

      Purpose:
      Only show items meeting a criteria
      Use in the format field,criteria,mode with the comma being the local delimiter

      *Mode* *Meaning*

      1 - !=
      2 - ==
      3 - <
      4 - >
      5 - <=
      6 - >=
      7 - Text not in field value
      8 - Text in field value

      In order to avoid some documents in tree documents.
      Do you think that it could be usefull or not ?


      the code of this 1.6.2 version could be downloaded at :
      http://modxcms.com/forums/index.php/topic,19755.msg123847.html#msg123847

      Look at the second post. Thanks for your feedbacks if any.
        • 7231
        • 4,205 Posts
        These are some great additions, thanks. I particularly like the limiting to certain documents/parents. I will try it out on my next project. I could see how a filter param could be useful.
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 25483
          • 741 Posts
          Can you use AjaxSearch to search through tv’s?

          I have a product catalog (made with tv’s) on a site that I want to be searchable.
            with regards,

            Ronald Lokers
            'Front-end developer' @ h2o Media

            • 5811
            • 1,717 Posts
            Can you use AjaxSearch to search through tv’s?

            Yes. The AjaxSerach takes into account the tvs linked with documents.
              • 25483
              • 741 Posts
              Quote from: coroico at Nov 19, 2007, 06:19 AM

              Can you use AjaxSearch to search through tv’s?

              Yes. The AjaxSerach takes into account the tvs linked with documents.

              Ok, I get a error with your 1.6.2 version if I do a search:

              Warning: mb_convert_encoding(): Illegal character encoding specified in /somepath/assets/snippets/AjaxSearch/AjaxSearch.php on line 190


              How can I fix this???


              And I have another question: Can I change the output of the results? Not in general, but only for 1 specific searchbox on my site. I like to output it like ditto does with my productcatalog (special layout which places the tv’s in it)
                with regards,

                Ronald Lokers
                'Front-end developer' @ h2o Media

                • 5811
                • 1,717 Posts
                Hi Ronald

                Regarding your bug :

                Could you check that your $database_connection_charset variable in the file /manager/includes/config.inc.php is correct. This variable should contains the connection charset of your mysql base (utf-8, latin1, ...) .
                If not, you get a warning in the ouput window.

                What is your page charset and your base connection charset ?
                  • 25483
                  • 741 Posts
                  It’s working now, the website is utf-8 and the database latin1.

                  Now I only need to get some template with the TV’s in it for that specific search
                    with regards,

                    Ronald Lokers
                    'Front-end developer' @ h2o Media

                    • 30939
                    • 27 Posts
                    If I start the search only with ... [!AjaxSearch!] ... I get an error after 4 seconds:

                    Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 524288 bytes) in /var/www/MODx/www.domain.de/assets/snippets/AjaxSearch/includes/AjaxSearch.inc.php on line 325

                    If I start the search with ... [!AjaxSearch? &depth=`8`!] ... the search does work.

                    The new parameters are very useful ... great work.
                      • 5811
                      • 1,717 Posts
                      Thanks for this feedback. I will try to redo this case and fix it.
                      For the moment i collect troubles and evolution requests before coming back with a robust version 1.6.3

                      This discussion is closed to further replies. Keep calm and carry on.