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

    I have AjaxSearch working fine but I thought I’d like to jazz up my search results a little bit. Each one of my pages has an image TV assigned to it and I was wondering if it’s possible to display this TV next to the page that’s been recovered on the results page.

    I know Ditto can do this when displaying results, but I’m guessing AjaxSearch doesn’t work the same way?

    Update

    I have managed to find out how to search for and display images - however I wish for the image in the TV to be displayed based on the recovered pages, not whether the image name contains any keywords. Any ideas?
      • 5811
      • 1,717 Posts
      @Thehen

      If your search find the correct document with the linked TV :
      - create your own tplResultAjax template (or tplResult for non ajax mode) by copying the default template you use
      - allow the displaying of TV in your snippet call:
      &tvPhx=`tv:displayTV`
      and use the placeholders in your new result template:

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

      Let me know If it’s not clear or if you have some difficulties
        • 28870
        • 10 Posts
        I am having the exact same problem and could use another nudge in the right direction. I’m sure my mistake is something stupid. I have a custom TV called product_image_thumb. My AS call is :
        [!AjaxSearch? &ajaxSearch=`0` &debug=`3` &tplResult=`AjaxproductList` &tvPhx=`tv:displayTV` &parents=`14` &depth=`1`!]

        My template is:
        <div class="product_list_odd">
        <div class="product_list_content">
        <h3><a href="[+as.resultLink+]">[+as.pagetitle+]</a></h3>

        <p>[+as.summary+]</p>
        </div><!---product_list_content-->
        <div class="product_list_info">
        <div class="product_list_img">
        <a href="[+as.resultLink+]"><img src="[+as.product_image_thumb+]" /></a>
        <div style="width: 100%; height: 1px; clear: both;"></div>
        </div><!--product_list_img-->
        </div><!--product_list_info-->
        <div style="width: 100%; height: 1px; clear: both;"></div>
        </div><!--product_list_odd-->
        I get nothing for the custom tv. Please help!
          • 5811
          • 1,717 Posts
          I am having the exact same problem and could use another nudge in the right direction. I’m sure my mistake is something stupid.
          In fact this is the implementation of the feature tvPhx that is stupid !!!

          do a search with a part of the name of an image and I am pretty sure that you will get your image with the result !!!

          Why ? Because with the current 1.8.1 version, you get a TV value, only if the search has found your term in the TV (product_image_thumb).

          As It’s not very pratical grin and It would be better to get any value of TV linked with the document found undecided not only those which contain the searched term, find as a quick fix, a new version of the search.class.inc.php file. Replace the existing file locating in the ajaxSearch/classes folder with this file. With this fix you will get all TVs linked to the document found

          I have open an issue about this topic: AJAXSEARCH-22
          I will port this fix to the current 1.8.2 version currently in development.

          Display TVs with tvPhx (mootools mode) and Display TVs with tvPhx demos have been modified consequently. With these demos, if you use "2007-10" as search word you get the content of the TV asTag1. Otherwise, you get nothing.

          Thanks for this feedback.

          @thehen
          This fix will solve your request too
            • 849
            • 19 Posts
            Nice work coroico, really helpful man wink works perfectly, by the way, is this suppose to be added on the new AjaxSearch snippets? because the 1.8.3 version doesn’t work with tv’s, even the tv values are used as the search term.
              • 5811
              • 1,717 Posts
              because the 1.8.3 version doesn’t work with tv’s, even the tv values are used as the search term.
              A example, try to search "japon" as search term on this demo page. You get only the Kanji page which is tagged with "japon".

              By searching "2007-10" which is an other value for the tag "as_tag1", you get the doc tagged by this value. But the extract displayed is not correct. I don’t know why, but a part of the content is dispayed with the value of tag. But this dispay error is different of a wrong search with a tv.

              What are your ajaxSearch snippet call, what are your tv value ?
                • 19975
                • 429 Posts
                Hi coroico,

                I’m having the same issue, can’t get TVs to show in AjaxSearch which is giving me stress sad. Should I upload your ’search.class.inc.php’ file. Will this ensure that 1.8.3 shows TVs within the results?

                Thanks,
                  Martin Sanders - Design & Web Development
                  • 33982 ☆ A M B ☆
                  • 476 Posts
                  I followed the instructions above and spent several hours trying to get this to ALWAYS output the T.V. image regardless of whether or not the image file name was in the search term or not, but I could not get it to output the image T.V. So I did a bit of a hack that’s not pretty and I can imagine it may slow things down a bit, but I tried it anyway and to my surprise, it works. I brought in Ditto in the AS results to grab the image T.V. ... here’s what I did:

                  Ajax Search snippet call:
                  [!AjaxSearch? &ajaxSearch=`0` &parents=`22` &AS_landing=`43`!]


                  I modified the result.tpl.html in assets/snippets/ajaxSearch/templates/result.tpl.html to this:
                  <div class="ajax_search_box"><!-- begin .ajax_search_box -->
                  <a href="[+as.resultLink+]" title="[+as.pagetitle+]">[+as.pagetitle+]</a>
                  <p>[+as.extract+]</p>
                  [[Ditto? &documents=`[+as.id+]` &tpl=`ajax_search_thumb_tpl`]]
                  </div><!-- end .ajax_search_box -->
                  


                  Then for ajax_search_thumb_tpl, I have this:
                  <img src="[+img_01+]"/>


                  Hey, I know it’s ugly, but it worked. It’s hacky, but I just can’t seem to get Ajax Search to allow me to customize my search results how I want them, so I brought in Ditto. Maybe I didn’t read the AS docs well enough (I thought I did at least), but this is what has worked for me.
                    Precision Web Development ... SmashStack.com