We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27733
    • 99 Posts
    Good day all,
    I’ve just come across a possible buggy behavior while validating pages:
    When I follow a link from a search result, a <body> tag is appended to the bottom of the html (after the closing </body> tag). This, of course, causes a validation error. Anyone know how to fix this?
    Cheers, Jim
      ------
      Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
      • 27733
      • 99 Posts
      I’m running 1.7.1 and the following calls are made:

      Search call:
      [!AjaxSearch? &ajaxSearch=`0` &AS_showResults=`0` &AS_landing=`8`!]

      Landing page:
      [!AjaxSearch? &ajaxSearch=`0` &advSearch=`allwords` &AS_showForm=`0` &extractLength=`250` &grabMax=`8`!]
      <!--search_terms-->


      The dev site address for this project is: http://dev2.sparkmediagroup.com

      I can’t reproduce it on your demo site either. So, so far, it’s a bit of a mystery.

      Thanks for your help smiley
        ------
        Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
        • 5811
        • 1,717 Posts
        How do you use the highlight plugin ? Probably yes by default wink As you have a "<body onload="">" this could produce this kind of issue. Look at "Search Highlight plugin Usage (optional)" chapter of the AS documentation to solve it.
          • 27733
          • 99 Posts
          OK, thanks for your help! Yes, the highlight plugin was the source of the problem. For now I’ve simply disabled it however, the highlighting still works (how’s that possible?).
            ------
            Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
            • 5811
            • 1,717 Posts
            May be your page is always cached

            Rather to disable it, in your template, try to frame a part of it,(e.g: [*content*]), with an html comment like ’<!--highlight-->’
            And change the line:
            $body = explode("<body>", $output); 
            by
            $body = explode("<!--highlight-->", $output);


            This will limit the highlighting of search words to this part of your document.
              • 27733
              • 99 Posts
              When you say frame part of the content with <!--highlight-->, I need clarification. How would that look? If you could give me a brief block of example code that would be great. I only ask because if I’m interpreting your suggestion correctly, it means doing something that’s otherwise unintuitive (wrapping the entire content block in a comment). Thanks for your input!
                ------
                Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
                • 5811
                • 1,717 Posts
                @smg6511
                Sorry If I am not very clear in my explanations ... Find below as example the template of the AS demo site:
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=[(mod2_charset)]" />
                <title>[(site_name)] | [*pagetitle*]</title>
                <meta http-equiv="keywords" content="modx, free cms, content management system, content management, cms, application framework, ajax, ajaxsearch" />
                <link rel="stylesheet" type="text/css" href="assets/templates/ajaxSearch/css/main.css" media="screen" />
                <script src="assets/templates/wangba/js/wgbaCom.js" type="text/javascript" ></script>
                <base href="[(site_url)]"/>
                </head>
                <body id="type-a">
                <div id="header">
                	<div id="logo">
                	  <h1>AjaxSearch</h1>
                	</div>
                  [!Wayfinder? &startId=`50` &level=`2` &outerTpl=`wfOuter`  &innerTpl=`wfInner` &rowTpl=`wfRow` &hereClass=`active` &firstClass=`first` &lastClass=`last` &titleOfLinks=`description`!]
                </div>
                <div id="content">
                <!--highlight-->
                	<div id="colOne">
                       [*content*]
                	</div>
                <!--highlight-->
                </div>
                <div id="footer">
                	{{ajaxSearchFooterEN}}
                </div>
                </body>
                </html>
                As you can see the <!--highlight--> tag frames the div id="colOne" so, the search occurs only in this div section (and not in the header, menu, footer ...)
                For that you need to update your search_highlight plugin by replacing the line 61 by
                $body = explode('<!--highlight-->', $output); // break out the page




                  • 27733
                  • 99 Posts
                  OK, thanks coroico! One last question then: is it possible to frame another section as well? For example,

                  in the main content area:
                  <!--highlight-->
                  [*content*]
                  <!--highlight-->


                  then in a side column:
                  <!--highlight-->
                  [*sidebar-content*]
                  <!--highlight-->


                  Or is only one pair allowed?

                  Thanks again for all your help.

                  Cheers,
                  Jim
                    ------
                    Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
                    • 5811
                    • 1,717 Posts
                    @smg6511
                    is it possible to frame another section as well?
                    No, the explode function used line 81 by the algorithm will produce $body[0], $body[1] and $body[2]. And the part between the two tags is in $body[1].
                    With 2 two sections you will generate 5 differents value for $body and you will be interested by $body[1] and may be by $body[3] sad
                    But as your remark is interesting, if you can wait, i will try to find a more general solution.
                      • 5811
                      • 1,717 Posts
                      @Smg6511

                      Jim, find enclosed a new version (1.3) of the search-highlight plugin, wich can run with multi highlighted sections.
                      Start each section you want highlight in documents by "<!--start highlight-->" and end this same section with "<!--end highlight-->"
                      In your example, in the main area:
                      <!--start highlight-->
                      [*content*]
                      <!--end highlight-->
                      and in the side column
                      <!--start highlight-->
                      [*sidebar-content*]
                      <!--end highlight-->

                      If a section is not ended by the "<!--end highlight-->" tag, the section will be ignored