On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Find below some indications on how to migrate from AjaxSearch 1.8.5 to AjaxSearch 1.9.0

    These recommandation could be applied for previous releases like 1.8.1, 1.8.3 or 1.8.4 too


    1/ ============================ Deprecated parameters

    searchWordList

    1.8.5 :
    ---- &searchWordList user function (optional)
    to define a search word list: [user_function_name,params] where params is an optional array of parameters

    1.9.0 : The option list should be now set in the input template.
    For instance you could use a snippet to get some Tv values.

    resultsPage

    1.8.5 :
    A very old parameter not really used. If used, Should be replaced by landingPage


    showMoreResults

    1.8.5 :
    ---- &showMoreResults [1 | 0] (optional)
    If you want a link to show all of the results from the ajax search.

    1.9.0 : this parameter is useless as soon as you define a moreResultsPage.


    2/ ============================ Renamed parameters

    For a better and a simpler undertstanding some parameters have been renamed

    AS_showForm => showInputForm
    AS_landing => landingPage
    AS_showResults => showResults


    3/ ============================ Renamed $_POST and $_GET variables

    Some $_POST and $_GET variables have been renamed.

    AS_search => search


    4/ ============================ Renamed parameter values

    tvPhx

    If you previously use the tvPhx parameter with &tvPhx=`tv:displayTV`
    You need now define which Tvs you would like use.

    1.8.5 :
    &tvPhx : Set placeHolders for TV (template variables)

    0 : disallow the feature
    ’tv:displayTV’ : set up placeholders for each TV (named tvName) linked to the documents found (default)


    1.9.0 :

    &tvPhx [ [ + | - ] [ : tvlist] ] - by default ’’

    The parameter tvPhx define which additional tv will be added as placeholder.

    e.g:

    &tvPhx=`tv1,tv2,tv3` - tv1, tv2, Tv3 are added as placeholders
    &tvPhx=`+:tv1,tv2,tv3` - tv1, tv2, Tv3 are added as placeholders
    &tvPhx=`+` - all tvs of the site are added as placeholders

    &tvPhx=`-` - all tvs of the site are added as placeholders
    &tvPhx=`-:tv1,tv2,tv3` - all tvs of the site except tv1, tv2, Tv3 are added as placeholders

    &tvPhx=`` - no tv defined as placeholders.

    The following placeholders are anabled with the tv:

    [+as.tvname+], [+as.tvnameShow+], [+as.tvnameClass+]

    Where tvname is the MODx name of a TV

    [+as.tvname+] is the HTML output of your TV
    [+as.tvnameShow+] = 1 if the TV is not NULL
    [+as.tvnameClass+] :
    - ajaxSearch_resultTvname for the non ajax results (&tplResult)
    - AS_ajax_resultTvname for the ajax window (&tplAjaxResult)

    The tv value could be used with the filter parameter (see &filter)

    As withTvs includes the TV as a new field in the select clause of the mysql query,
    tvPhx append the content of the selected tv after the search and before filer.


    5/ ============================ Add PagingType 0 to your AjaxSearch snippet calls

    The default pagingType is 1. So to keep your previous look & feel you need to add &pagingType=`0`

    With the non-ajax mode, this allow the pagination as 1.8.5
    With the ajax mode this disabled the pagination of results for a group of results.

    1.9.0 :

    &pagingType [ 0 | 1 | 2 | 3 ] : type of pagination

    Default: 1

    0: Results Pages 1 | 2 | 3
    1: Previous - X-Y /Z - Next
    2: X-Y /Z - Show more 10 results

    Type 0 for non-ajax mode only
    Type 1 for non-ajax and ajax mode
    Type 2 for ajax mode (Jquery only)


    6/ ============================ define the "init" css class to prevent javascript disabling

    When using ajax mode, it’s better to plan that javascript could be disabled.
    In this case you need to add a landingPage to see the search results and define the css class "init" to mask the ajaxSearch_output div when javascript is disabled. Simply add in your css file:

    #ajaxSearch_output.init {
    border: none;
    background-color: #FFF;
    }

    7/ ============================ Customize the look & field of your search results display

    For a better look & feel of your results display define:

    .ajaxSearch_resultsDisplayed, .AS_ajax_resultsDisplayed : to style the number of results displayed

    .ajaxSearch_resultsDisplayed, .AS_ajax_resultsDisplayed {
    font-weight:bold;
    color:#CC0000;
    font-size:90%;
    display:block;
    float:right;
    }

    .ajaxSearch_grpResultsDisplayed.AS_ajax_grpResultsDisplayed : to style the number of results by group displayed

    .ajaxSearch_grpResultsDisplayed, .AS_ajax_grpResultsDisplayed {
    font-weight:normal;
    color:#CC0000;
    font-size:90%;
    display:block;
    float:right;
    }

    .ajaxSearch_grpResultName, .AS_ajax_grpResultName : to style the group of results

    .ajaxSearch_grpResultName, .AS_ajax_grpResultName {
    background:url(images/img04.jpg) no-repeat left 50%;
    font:bold 1em Arial, Sans-serif;
    padding:5px 0 5px 15px;
    margin:3px 0;
    }

    And if you use the pagingType parameters :

    .ajaxSearch_paging {
    display:block;
    margin:5px 0 10px;
    }
    .paging1, .paging2 {
    padding:5px 0 10px;
    margin:0 0 5px;
    }
    .paging1Infos{ margin:0 5px 5px; color:green;}
    .paging1Prev{ width:16px; margin:0 3px 0 0;display:block; float:left; text-indent:-3000px; background:url(images/asprev.png) 0 center no-repeat; }
    .paging1Next{ width:16px;display:inline-block;text-indent:-3000px; background:url(images/asnext.png) 0 center no-repeat; }

    .paging2More{ margin:10px 10px; padding:8px;background:url(images/asnext.png) 0 center no-repeat;}
    .paging2Text{ margin:0 0 0 12px; color:green;}

    .ajaxSearch_currentPage {
    color:#6F9303;
    font-weight:bold;
    }

    look at documentation/someCssExamples/search.css for some examples.


    8/ ============================ New labels added

    Six labels have been added. So may be some labels could be missing for your language.

    Used to display the number of results found:
    $_lang[’as_resultsTextSingle’] = ’%d result found.’;
    $_lang[’as_resultsTextMultiple’] = ’%d results found.’;

    Used to display the total number of results displayed:
    $_lang[’as_resultsDisplayed’] = ’Displayed: %d’;

    Used to display the number of results displayed by group:

    $_lang[’as_grpResultsDisplayedText’] = ’(Displaying %d - %d of %d)’;

    Used by pagingType 1:
    $_lang[’as_paging1Text’] = ’%d - %d / %d’;

    Used by pagingType 2:
    $_lang[’as_paging2Text’] = ’Show more %d results’;
    • hi,

      as advised by coroico smiley just a word here to say that, for those savages like me who directly customize coroico templates instead of creating their own ones (savages i said smiley), the name of the templates have changed the same way the vars parameters have

      then, for example "layout.tpl.html" is now input.tpl.html

      the same for paging templates, depending of the paging you use 0|1|2 templates are paging0.tpl.html and so on

      be aware of something too, if you don’t want to use grpResult you should erase the conteneur tags around

      [+as.headerGrpResult+]
      [+as.footerGrpResult+]
      [+as.listResults+]
      [+as.footerGrpResult+]


      in grpResult.tpl.html or else, for what i’ve seen, it will display an empty conteneur in the source code (in fact, an empty conteneur opening tag smiley)

      Have swing
        réfléchir avant d'agir
      • be aware of something too, if you don’t want to use grpResult you should erase the conteneur tags around

        Code:

        [+as.headerGrpResult+]
        [+as.footerGrpResult+]
        [+as.listResults+]
        [+as.footerGrpResult+]
        virtualgadjo, if you don’t want use the grpResult, the better thing to do is ... nothing smiley

        Look at this demo and search "asterix" (a famous guy as you know!), you get one result framed in a group result named "grpResult_site_wide". Look at the attached screen shot of the source code (view source chart Firefox plugin) named without_category.

        Run the same demo with &category. Look at the with_category screenshot and as you can see, except the image added in this demo, you get ... nearby the same source code. In the first case, only one group is used "site_wide". In this second case, the "grpResults_Arts" is used.

        So,IMHO I think it’s better to keep the grpResult template rather to change the original templates.

        Thanks for your feedback regarding the names of the templates (layout/input)

        I have opened a how-to section on the demo site.
        • Hi Coroico,

          about grpResult, that’s what i did first, ie nothing smiley but, having a look at my source code (i’m a bit obsessive about that...) i didn’t understand what was that opened div in my paging content. Then i’ve added &grpResultDef=`0` to my ajaxSearch call, same thing...
          The only way i found out to have it disappear was to erase it in the grp template.
          actually, i made a test before and replaced it by a p tag -> an opened p tag in the code smiley

          just an example for you to see, if i use this in the template

          [+as.grpResultsDef:is=`1`:then=`
          <div>
          [+as.headerGrpResult+]
          [+as.footerGrpResult+]
          [+as.listResults+]
          [+as.footerGrpResult+]
          </div>
          `:else=`

          with this call
          [!AjaxSearch? &ajaxSearch=`0` &showResults=`1` &showInputForm=`0` &showPagingAlways=`1` &pagingType=`0` &grabMax=`10`!]

          or
          [!AjaxSearch? &ajaxSearch=`0` &showResults=`1` &showInputForm=`0` &showPagingAlways=`1` &pagingType=`0` &grabMax=`10` &grpResultDef=`0`!]

          the resulting html will be
          <p class="ajaxSearch_resultsInfos">36 résultats trouvés pour "<span class="ajaxSearch_highlight ajaxSearch_highlight1">scpi</span>".<span class="ajaxSearch_resultsDisplayed"> Affichés : 10</span></p>
          <div>
          <p class="ajaxSearch_grpResultName">
          <span class="ajaxSearch_grpResultsDisplayed">Résultat(s) de 1 à 10 sur 36</span></p>

          that opening div tag (which is not closed) only disappear if i erase it from the grpResult.tpl.html. Being a bit obsessive as i said i can’t prevent myself from erasing both the opening and the closing tags then, even if the closing one does not appear in the source code smiley

          i must have missed something somwehere smiley and will have a closer look at all that as soon as the website i’m working on is finished

          i must admit it’s my very first cms(f) website, i’ve been coding all and everything from scratch for 10 years and it’s new for me not to have written every single line of what i use then i’ve had to learn snippets, chunks, TVs, creating personal modules to manage specific contents (modx is really fantastic and surprisingly easy at that thanks to the ’a’ and module ’id’ vars...) and so on, in less than a month during the prod process... so, please, do forgive me if, sometimes, i use what i call "savage methods" to achieve what i’m looking for a bit faster than i should... laugh

          Have swing
            réfléchir avant d'agir
          • can somebody please explain how to use this the right way in plain English?
            • can somebody please explain how to use this the right way in plain English?
              What do you not understand ? the initial post or the discussion with virtualgadjo ?
              • :) must be my poor Frenchy English smiley

                have swing
                  réfléchir avant d'agir
                • can somebody provide a working example
                  • A working example of how migrate from AjaxSearch 1.8.4 to 1.9.0 ? is this your question ?

                    With ajaxSearch 1.8.4 you could customize your search feature by using some parameters. Some of these parameters are now deprecated and some new parameters have been added. The initial post list these deprecated/updated/new parameters.
                    • Coroico, any update on the state of AjaxSearch for MODx Revolution ?