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
    Like David i don’t get any search results when i tried to search Line card. Tested with firefox with javascript enabled.

    I am having problems with the Ajax Search showing HTML formatting when the results are returned.

    The weird thing is, this only happens when there is more than one search term.


    For informations, i am working on the next release of AjaxSearch (1.7) and one of the next improvements should correct this issue. For a similar issue, look at http://modxcms.com/forums/index.php/topic,5357.msg128909.html#msg128909

    Could you give use your snippet call and the document extract (html code) where the issue occurs. Thanks.


      • 31290
      • 37 Posts
      The AjaxSearch call I am using is the standard blank call:
      [!AjaxSearch!]


      This is an example of HTML that is causing the search to show CSS formatting:
      <div id="centerboxBlue">
      <span class="categorySub">New Line Card!</span>
      <div style="float: right">
      <a href="assets/files/PDF/linecard.pdf" style="padding-left: 10px" target="_blank"><img height="127" src="assets/images/linecard3d.gif" width="130" /></a>
      </div>
      <p align="justify">
      VMI introduces its new line card. Take a look to see our full line of products and services by clicking on the thumbnail to the right. Ask your Van Meter Industrial Representative for a hard copy of the new line card!
      </p>
      </div>
      


      The code above is from the homepage of my site: www.vanmeterindustrial.com
      It is the blue div container in the middle of the page titled "New Line Card!"

      Like I mentioned before though, when I search for only one word, and this page shows as a result, there is no HTML or formatting, only when two words are used.

      On a side note: What would cause your computer to show no results, when it works fine on my computer?
        • 25663 MODX Staff
        • 12,272 Posts
        You’re likely logged into the manager and it’s also adding in JS calls to the head of the document making it work for you (being logged in) but not for others (not logged in). Like David, I too suspect you’ve got a conflict with all the JS in your document head.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 5811
          • 1,717 Posts
          VanMeter, to do a test i create a new document on my site with your html code (i change only the image and i haven’t the css style, otherwise this is the same code).
          For this test I change the snippet Ajax Call to [!AjaxSearch? &AS_opacity=`0.9` &parents=`28`!] in order to be the closest of a [!AjaxSearch!] snippet call but with a limited access to some documents (&parents=`28`) grin

          The search of line card runs well with FF2.0. Try it !
          I have done this test with FF2.0 as a non-logged web user with an empty history (js files and so on ...)

          I do the same test with IE6.0 and like you i get a light different result >:( With IE6.0 i get the following line at the end of the extract : New Line Card! card.pdf" style="padding-left: 10px" target="_blank">
          This line comes from the document. This issue should be linked with http://modxcms.com/forums/index.php/topic,5357.msg128909.html#msg128909

          I need to investigate to understand the differences, but i think that they don’t explain why on your site you don’t get any results.

          This a temporary test, i will remove it in few days, once you have run it
            • 31290
            • 37 Posts
            First of all I want to thank all of you guys for your continued support with this problem I’m running into...

            coroico - Below is my CSS, I think the reason you may not be seeing the formatting I am referring to is because there is no stylesheet. Try adding the CSS below to your test page and see if it changes the results at all.

            Also, once you do this can you send me a link to your test page? I went to your homepage but couldn’t find any link to the test page (it probably doesn’t help that I can’t read your language tongue) I would like to test your search as well!

            .field {
            	color: navy;
            	height: 16px;
            	font-size: 10pt;
            	border: solid 1px black;
            	outline-color: #00d;
            	outline-width: 1px;
            	background: #fff;
            }
            body, html {
            	margin: 0;
            	padding: 0;
            	background: #00204f;
            	color: #000;
            	height: 600px;
            }
            #wrap {
            	position: relative;
            	background: #00278a;
            	width: 795px;
            	float: left;
            	margin: 0;
            }
            #header {
            	width: 100%;
            	height: 92px;
            	position: relative;
            	padding: 0;
            	margin-bottom: 0;
            	background: url(http://www.vanmeterindustrial.com/assets/images/index_01.jpg) no-repeat left;
            }
            #header h1 {
            	padding: 0;
            	margin: 0;
            }
            #nav {
            	border-top-style: solid;
            	border-width: 1px;
            	border-color: #b7daff;
            	background: #000;
            	float: right;
            	width: 668px;
            	height: 28px;
            	margin-bottom: 0;
            	margin-top: 0;
            	margin: 0;
            	padding: 0;
            	background-image: url(http://www.vanmeterindustrial.com/assets/images/vmi/header_bg.png);
            	background-repeat: repeat-x;
            	z-index: 50;
            }
            #nav ul {
            	margin: 0;
            	padding: 0;
            	width: 100%;
            	border-bottom-style: solid;
            	border-width: 1px;
            	border-color: #b7daff;
            	position: relative;
            }
            #main {
            	background: #fff;
            	float: right;
            	width: 668px;
            	min-height: 461px;
            	max-height: 100%;
            	overflow: hidden;
            }
            #sidebar {
            	background: #99c;
            	float: left;
            	width: 127px;
            	height: 100%;
            	margin-top: 0;
            	background-repeat: no-repeat;
            	margin: 0;
            	padding: 0;
            }
            #copylogo {
            	height: 43px;
            	width: 668px;
            	float: right;
            	background: url(http://www.vanmeterindustrial.com/assets/images/footer_copyright.jpg) no-repeat top center;
            }
            
            
            #footer {
            	background-repeat: no-repeat;
            	height: 22px;
            	width: 668px;
            	float: right;
            	text-align: center;
            	color: #2382f6;
            }
            #footer p {
            	padding: 0;
            	margin: 0;
            }
            #footer a {
            	color: #2382f6;
            	text-decoration: none;
            	font: bold 10pt arial;
            }
            #footer a:hover {
            	color: #fff;
            }
            #menu_top {
            	position: relative;
            	z-index: 100;
            	float: left;
            	margin: 0;
            	padding-right: 0px;
            	list-style-type: none;
            }
            #menu_top li {
            	position: relative;
            	float: left;
            	background: url(http://www.vanmeterindustrial.com/assets/images/vmi/header_link_bg.png) repeat-y right 0;
            }
            #menu_top li a {
            	display: block;
            	float: left;
            	height: 22px;
            	padding: 6px 10px 0;
            	color: #FFF;
            	text-decoration: none;
            	white-space: nowrap;
            	font: bold 13px Arial;
            }
            #menu_top li a:hover {
            	height: 21px;
            	padding: 7px 9px 0 11px;
            	background: #4e4d4e url(http://www.vanmeterindustrial.com/assets/images/vmi/header_link_hover_bg.png);
            }
            #menu_top ul {
            	position: absolute;
            	display: block;
            	float: none;
            	top: 28px;
            	left: -1px;
            	width: 125px;
            	margin: 0;
            	padding: 0;
            	border-style: none solid solid;
            	border-color: #b7daff;
            	-moz-opacity: 0.9;
            	opacity: 0.9;
            	filter: alpha(opacity=80);
            	background: #00045f;
            }
            #menu_top ul li {
            	display: block;
            	float: none;
            	margin: 0;
            	padding: 0;
            	background: none;
            }
            #menu_top ul li a {
            	display: block;
            	float: none;
            	height: auto;
            	padding: 2px 5px;
            	font-size: 12px;
            	font-weight: bold;
            }
            #menu_top ul li a:hover {
            	color: navy;
            	height: auto;
            	padding: 1px 5px 2px;
            	border-style: solid none;
            	border-color: #b7daff;
            	border-width: 1px;
            }
            #pup {
            	position: absolute;
            	visibility: hidden;
            	z-index: 200;
            	width: 200px;
            }
            #pup2 {
            	border-style: solid;
            	border-width: 1px;
            	width: 200px;
            	border-color: #000270;
            }
            #pup3 {
            	border-style: solid;
            	border-width: 3px;
            	width: 200px;
            	border-color: #2382f6;
            	-moz-opacity: 0.9;
            	opacity: 0.9;
            	filter: alpha(opacity=90);
            	background: #FFF;
            }


            As far as being logged in, and this effecting the search results, I don’t think this is the issue. I have tried the search on other computers within my company and it has worked fine. But I just had my brother try it at home and it doesnt work. Could this be something to do with being on an internal network?
              • 31290
              • 37 Posts
              coroico - I found the same problem I am running into on your site! Check out the attached images.

              I searched for card and then for "world phonecards" and it showed results with formatting, then when I search for just "phonecards" it didn’t show the formatting...

              This is the same problem I am running into!


              EDIT TO REMOVE IMAGES. THNX!
                • 5811
                • 1,717 Posts
                That’s right ! Now i understand your meaning sad and i have from now on a good example grin

                Ok, i will try to solve this issue. Thanks for this feedback.

                Now as i have understood the issue, could you remove the view of my web site from your post.
                I do the same with the test "line card" on my site

                I come back with a fix as soon as possible.
                  • 5811
                  • 1,717 Posts
                  Hi VanMeter,

                  Find enclosed, as christmas gift wink, a fix (1.6.2e) for your issue . This download zip file is a fix to the 1.6.2 version of AjaxSearch. About this release look at : http://modxcms.com/forums/index.php/topic,5357.msg123851.html#msg123851

                  It ’s a cumulative patch which includes 1.6.2b, 1.6.2c and 1.6.2d fixes

                  Just for information, this bug is a true testbook case. Let’s me explain you why ...

                  Here is the code of the build of the search results which must be displayed :
                  $toAdd = PrepareSearchContent( $text, $length=200, $search[0] );
                  strip_tags( $text );
                  foreach ($search as $searchTerm) {
                    if (preg_match('/' . preg_quote($searchTerm) . '/i', $text)) {
                      if ($count > 1) { // The first summary was already extracted above
                        $toAdd = SmartSubstr( $text , $length=200, $searchTerm );
                    	}
                    	$summary .= preg_replace( '/' . preg_quote( $searchTerm, '/' ) . '/i', '<span class="AS_ajax_highlight AS_ajax_highlight'.$count.'">\0</span>', $toAdd ) . ' ';
                  

                  First you prepare the content result got from the database (PrepareSearchContent function) by cleaning particulars characters (like Modx Tags)
                  Then :
                  - you strip HTML tags (remove tags from the text. strip_tags is a native php function)
                  - and for each search term you get a Smart substring (get 200 characters around you search term)
                  - then you add the css style to highlight the term found

                  The prepareSearchContent function is :
                  function prepareSearchContent( $text, $length=200, $search ) {
                  
                      ....
                      
                      // Remove modx sensitive tags
                      foreach ($modRegExArray as $mReg){
                        $text = preg_replace($mReg,'',$text);
                      }
                    	// strips tags won't remove the actual jscript
                    	$text = preg_replace( "'<script[^>]*>.*?</script>'si", "", $text );
                    	$text = preg_replace( '/{.+?}/', '', $text);
                    	// $text = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2', $text );
                    	// replace line breaking tags with whitespace
                    	$text = preg_replace( "'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text );
                    
                    	return $this->smartSubstr( strip_tags( $text ), $length, $search );
                    }
                  The goal of this code is to clean the text got from the database and get the first extract (first search term)

                  The main problem of this code is that :
                  In the first step, you use the PrepareSearchContent function to clean the code and get the first extract ($toAdd) in same time.
                  BUT you clean the text ($text) only for this first extract. Because, $text is a local variable cleaned only in the PrepareSearchContent and never returned to the calling code undecided
                  So, for the following search terms, the code is not cleaning. The strip_tags function has worked only for the first search term. Is typically the issue you raised.

                  for the correction of this issue look at :
                  - snippet-ajaxSearch-tpl.php : lines 499 to 504
                  - AjaxSearch.php : lines 98 to 103
                  - AjaxSearch.inc.php (includes folder) : lines 213 to 236

                  Install this fix and let me know if it ’s ok for you now. Overwrite the snippet code of AjaxSearch with the content of AjaxSearch.inc.php snippet-ajaxSearch-tpl.php

                  I have installed this fix on my web site, so do not hesitate laugh, try it with "world phonecard" as search terms on my site

                  But keep in mind, because it’s a limitation, that the strip_tags function works well only if the html tags are correctly writed and ended.

                  Ryan, not sure, but i think that this correction will fix the issue raised by Paul : http://modxcms.com/forums/index.php/topic,5357.msg128909.html#msg128909
                  Ok could i check that ? In fact the strip_tags is only applied on the text content not on title nor on description as suggested by Paul. I will correct that.

                  Regarding http://modxcms.com/forums/index.php/topic,20136.msg124792.html#msg124792
                  I will ask to Rick.

                  The version 1.7 of AjaxSearch which is in preparation, will include this new fix and some others enhancements.

                  My last concern is that when a search string is found inside a html tag (e.g an image name), this term could be erased before the displaying of the result. So in this case, i think i will not displayed the result as the search term can’t be seen and highlighted sad

                    • 31290
                    • 37 Posts
                    Woohoo! Thank you so much for this fix Coroico! Your help and support on these forums is greatly appriciated by myself, and probably hundreds more!

                    I will install this fix and look forward to version 1.7. Thanks again!

                    Note: I have also removed the images of your website, sorry about posting that without your consent, I figured it would give you an example to work from. Thanks!!!!
                      • 31290
                      • 37 Posts
                      Hey, I just uploaded the new files in your ZIP file, but I think you forgot to include a file.

                      With the initial install is says to copy the contents of snippet-ajaxSearch-tpl.php to the Snippet called AjaxSearch, but in your directions it said to copy the contents of AjaxSearch.inc.php into the Snippet.

                      I opened AjaxSearch.inc.php and it doesn’t look like the correct snippet code.

                      I didn’t see any updated version of snippet-ajaxSearch-tpl.php if your ZIP file attached. Can you please send me the updated snippet code, or let me know if I am completely confused. haha. Thanks!