We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Can anyone advise the non ajax search string i would need to use to search a selection of TVs and how to reference these TVs in a chunk which the results call using to display content?

    This is my search call

    [!AjaxSearch? &ajaxSearch=`0` &AS_landing=`13` &AS_showResults=`0` &tplLayout =`searchBox` &tvPhx=`tv:displayTV` &whereSearch=`content|tv:Product_Name` !]


    This is the search results display call

    [!AjaxSearch? &ajaxSearch=`0` &AS_landing=`0` &tplResult=`searchResults`!]


    And here is the code for the "searchResults" snippet

    <div id="searchResults" class="searchResults">
    [*as.pagetitle*]
    Product Name: <h4><a href=[~[+as.id+]~] title="Find out more about [+as.Product_Name+]">[+as.Product_Name+]</a></h4>
    Product Description: <p>[+as.Product_Description+]</p>
    Product Thumb: <a href=[~[+as.id+]~] title="[+as.Product_Name+]"><img src="[+as.Product_Photo_Thumb+]" border="0"  alt="Find out more about  [+as.Product_Name+]" title="Find out more about  [+as.Product_Name+]"/></a>
    Find out more link: <p><a href=[~[+as.id+]~] title="Find out more about [+as.Product_Name+]">Find out more about [+as.Product_Name+]</a></p>
    <hr />
    </div>



    What currently happens is the search works, and pulls up the results, but the TV data is not rendered on screen.... Any ideas why?

    Thanks so much!

      • 5811
      • 1,717 Posts
      &whereSearch=`content|tv:Product_Name` is not correct. For TVs the search occurs in a concatenation of all TV values linked to the document. To restrict the search to the TV Product_Name, use &withTV=`Product_name`
      This parameter will restrict the tv_value used by whereSearch to the value of the Product_name TV.

      So use &withTV=`Product_name` instead of &whereSearch=`content|tv:Product_Name`
      As by default &whereSearch=`content|tv:tv_value` you can omit this parameter

      Use &withTV=`Product_name` in the two snippet calls (input form document and landing document)


      To retrieve Product_Name, Product_Photo_Thumb, Product_Description, ... keep &tvPhx=`’tv:displayTV’ to set up placeholders for each TV linked to the documents found.
        • 8168
        • 1,118 Posts
        coroico - thanks so much for your reply - I will have a go at implementing the bits and pieces you suggest and let you know how i get on! To clarify then, I don’t really need to specify which TVs to list - as i may as well let the search analyse them all. I just want the results to display a few which i identify in the chunk. Is that correct?
          • 8168
          • 1,118 Posts
          Could you possibly amend the code that i have used so that it would work? I have just gone through and amending the code on the site and am still having the same issues... There must be something really obvious that I am missing here... Thanks again!
            • 5811
            • 1,717 Posts
            [!AjaxSearch? &ajaxSearch=`0` &AS_landing=`13` &AS_showResults=`0` &withTV=`Product_name` &tplLayout =`searchBox`!]


            landing page:
            [!AjaxSearch? &ajaxSearch=`0` &withTvs=`Product_name` &tvPhx=`tv:displayTV` &tplResult=`searchResults`!]
              • 8168
              • 1,118 Posts
              Thanks coroico

              What would the calls be in the Chunk then? Would they remain as i have them already?

                • 5811
                • 1,717 Posts
                What would the calls be in the Chunk then? Would they remain as i have them already?
                Yes.

                By using, &tvPhx=`’tv:displayTV’ you set up placeholders for each TV linked to the documents found.

                &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!
                So you could use:
                [+as.Product_Name+], [+as.Product_NameShow+], [+as.Product_NameClass+]
                [+as.Product_Photo_Thumb+],[+as.Product_Photo_ThumbShow+],[+as.Product_Photo_ThumbClass+],
                [+as.Product_Description+],[+as.Product_DescriptionShow+],[+as.Product_DescriptionClass+]
                ...

                  • 8168
                  • 1,118 Posts
                  You are a true legend!!! You are my new hero! Thanks for helping with this - it all makes sense now! smiley smiley smiley
                    • 13481
                    • 97 Posts
                    It appears that template variables only show up if they match the searched term. Is there a way to pull in all template variables when a document is matched?

                    For instance, if document A is matched, the results would pull in all template variables for document A. I would also need all templage variables pulled in for Document A if one of it’s template variables matched, but Document A didn’t.

                    Also, the results seem to be heavily weighted on the content. I have some documents where all the template variables match, but no content matches (so 2-3 matches in the template variables), but those get outranked by one match in the content. Seems to me like the multiple template variable matches would rank higher.

                    James
                      • 5811
                      • 1,717 Posts
                      It appears that template variables only show up if they match the searched term. Is there a way to pull in all template variables when a document is matched?
                      Not without hacking the code. The next release will display all tvs when a document is matched, even if the tv don’t match.

                      Also, the results seem to be heavily weighted on the content. I have some documents where all the template variables match, but no content matches (so 2-3 matches in the template variables), but those get outranked by one match in the content. Seems to me like the multiple template variable matches would rank higher.
                      Ok, I will try to check this point, but as I have strongly redesigned the snippet, I will prefer do the tests on the next release (1.9 currently in development).