We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18373 ☆ A M B ☆
    • 3,141 Posts
    Hello folks,

    I’m stuck trying to do two things:

    1. stying the search result
    2. excluding the template variable ’contactpersonen’

    The website we’re running has a template variable filled with the names of the contact person for that specific page. This is shown on the page itself to the right. When using the search, eg searching for ’frans’, one of the contacts, it returns 19 results. Strange thing here: the name only shows up in the content field on one page.

    Now that isn’t too bad, but when it finds the name in the TV, it seems to refuse to display an extract of the page. For that reason I’ve tried to exclude the template variable - but I could not get that to work yet. Whenever I search for a term that appears on certain pages, it does show an extract of that page with the search term.

    Maybe I’m overlooking something or misspelled anything but I am really stuck on this.

    I just updated to ajaxsearch 1.8.4 (snippet+files) but that changed nothing on this.
    Before, it was running ajaxsearch 1.8.1. Modx version 0.9.3.1 (old, I know, that’s the downside of customizing it.. updating gets harder)


    This is the ajaxsearch call used:
    [!AjaxSearch? &ajaxSearch=`0` &AS_landing=`7` &formatDate=`d-m-Y` &depth=`3` &AS_showResults=`0` &tplLayout=`zoek-layout` &extractLength=`400` &whereSearch=`content:content|tv:NULL` &tplResults=`zoek-results` &tplResult=`zoek-result` &language=`nederlands`!]


    the ’zoek-layout’ chunk:
    <div id="zoekbox">
    [+as.showForm:is=`1`:then=`
    <form [+as.formId+] action="[+as.formAction+]" method="post">
    <div>
    
          <input id="zoekinput" class="cleardefault" type="text"  name="search" size="18" value="[+as.inputValue+]"[+as.inputOptions+]></input>
    
          <input id="zoeksubmit" type="image" src="img/zoekbutton.gif" name="sub" style="height: 25px; width: 14px;" value=">>"></input>
    </div>
    </form>
    `+]
    [+as.showIntro:is=`1`:then=`
    <p class="ajaxSearch_intro" id="ajaxSearch_intro">[+as.introMessage+]</p>
    `+]
    [+as.showResults:is=`1`:then=`
    [+as.results+]
    `+]
    </div>


    The ’zoek-paging’ chunk:
    [+as.tpl:is=`paging`:then=`
      <span class="ajaxSearch_paging">
        [+as.pagingText+]
        [+as.pagingLinks+]
      </span>
    `+]
    [+as.tpl:is=`pagingLinks`:then=`
      <a href="[+as.pagingLink+]">[+as.pagingText+]</a>[+as.pagingSeparator+]
    `+]
    [+as.tpl:is=`pagingLinksCurrent`:then=`
      [+as.pagingText+][+as.pagingSeparator+]
    `+]


    The ’zoek-result’ chunk:
    <div class="[+as.resultClass+]">
      <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[+as.pagetitle+]</a>
    [+as.descriptionShow:is=`1`:then=`
      <span class="[+as.descriptionClass+]">[+as.description+]</span>
    `+]
      <div class="[+as.extractClass+]"><p>[+as.extract+]</p></div>
     <span class="[+as.breadcrumbsClass+]">[+as.breadcrumbs+]</span>
    </div>


    the ’zoek-results’ chunk:
    [+as.noResults:is=`1`:then=`
      <div class="[+as.noResultClass+]">
        [+as.noResultText+]
      </div>
    `:else=`
      <p class="ajaxSearch_resultsInfo">[+as.resultInfoText+]</p>
      [+as.paging+]
      [+as.listResults+]
      [+as.paging+]
    `+]


    (all based on the defaults)

    Any clues on what I’m doing wrong?
      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
      • 5811
      • 1,717 Posts
      Hi Markieham,
      1/
      The website we’re running has a template variable filled with the names of the contact person for that specific page. This is shown on the page itself to the right. When using the search, eg searching for ’frans’, one of the contacts, it returns 19 results. Strange thing here: the name only shows up in the content field on one page.
      Keep in mind that all the TV are concatened to setup a tv_value. This is why you got several results when you search "frans". As "frans" is concatened with the others TV values, you retrieve it in some others search results.
      If you would like run a search only with this tv adds &withTVs=`contactpersonen`
      ---- &withTvs (optional)
      Define which Tvs are used for the search in Tvs
      a comma separated list of TV names
      by default all TVs are used (empty list)
      To understand what I mean, add &debug=`1` as parameter, do a search, open the assets/snippets/ajaxSearch/ajaxSearch_log.txt file and search "SQL". Copy/paste the entire SQL statement logged in the file into the SQL statement window of your phpMyAdmin tool, execute the sql statement and look at the results. Notice the content of the tv_value content field.

      2/
      Now that isn’t too bad, but when it finds the name in the TV, it seems to refuse to display an extract of the page.
      To display the Tv content use the tvPhx parameter as follow: &tvPhx=`tv:displayTV` and then in your result chunk use [+as.contactpersonenShow+], [+as.contactpersonenClass+], [+as.contactpersonen+] placeholders to show the informations required. See below as example:
      <div class="[+as.resultClass+]">
        <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[+as.pagetitle+]</a>
      [+as.descriptionShow:is=`1`:then=`
        <span class="[+as.descriptionClass+]">[+as.description+]</span>
      `+]
      [+as.contactpersonenShow:is=`1`:then=`<div class="[+as.contactpersonenClass+]"><p>[+as.contactpersonen+]</p></div>`+]
        <div class="[+as.extractClass+]"><p>[+as.extract+]</p></div>
       <span class="[+as.breadcrumbsClass+]">[+as.breadcrumbs+]</span>
      </div>


      Here is the extract of the readme file, regarding TV:
      &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)

      Placeholders for TVs are:

      [+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)

      e.g: AS_ajax_resultAsTag1, a tv named "asTag1"
      (take care, the first letter of tvName should be here an upper case)

      displayTV is a provided ajaxSearch function which render the Modx TV output. Don’t change the name!

      Your AS snippet call should look like something this:
      [!AjaxSearch? &ajaxSearch=`0` &AS_landing=`7` &depth=`3` &whereSearch=`content:content|tv` &withTVs=`contactpersonen` &language=`nederlands`!]


      - &AS_showResults=`0` is useless (the results should be displayed on the landing page)
      - Replace &whereSearch=`content:content|tv:NULL` by &whereSearch=`content:content|tv`. You need the tv wink
      - &extractLength=`400` is a parameter for the display. Not relevant for the search and for the display of the input form. Use it on the landing page.
      - Custom templates like result and results are not used to run the search too.

      And on the landing page (where the results are displayed):
      [!AjaxSearch? &ajaxSearch=`0` &showInputForm=`0` &formatDate=`d-m-Y` &depth=`3` &withTVs=`contactpersonen` &tvPhx=`tv:displayTV` &extractLength=`400` &whereSearch=`content:content|tv` &tplResults=`zoek-results` &tplResult=`zoek-result` &language=`nederlands`!]


      Why do you change the id of the input form ? You can also style the input form by using #ajaxSearch_form, #ajaxSearch_input, #ajaxSearch_submit and #ajaxSearch_output styles.

      You can get more information on the "Display TV’s with tvPhx" demo page.

      Hope that this help you.
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        I was trying to exclude the TV, not include them.


        Last night at aprox 1am suddenly it jumped into my mind. I forgot to change the call on the landing page grin

        Managed to get rid of the tv results now. (also with the info from your post)


        Thanks for the load of information on the phx tho - I did not know those options even existed in AjaxSearch. Perhaps the wiki needs to be updated (or I need to wear my glasses :p)


        The reason the ID was changed is cause we’re stubborn and want the ID’s in dutch, and it’s easier when using custom IDs in my opinion.


        Thanks a lot!
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 5811
          • 1,717 Posts
          Perhaps the wiki needs to be updated (or I need to wear my glasses :p)
          You are completely right. But for the moment, as lot of new features are on track, I prefer bring my efforts on the next releases 1.9 and the 2.0 for revolution.
          After, may be I will set up an e-book like that has been done for wayfinder by kongodo. I think that now ajaxSearch is become enought complex to require a book grin
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            Quote from: coroico at Nov 11, 2009, 10:07 AM

            I think that now ajaxSearch is become enought complex to require a book grin

            Definately XD
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.