We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31290
    • 37 Posts
    I wrote my first snippet for modx that inserts a SWFObject for JW Player (An FLV Video Player) but the AjaxSearch Highlighting is inserting code into the code that my snippet is rendering.

    Here is what it’s doing:
    <script type="text/javascript">
      var so = new SWFObject("http://www.wernermn.com/assets/videos/player.swf","mpl","470","550","9");
      so.addVariable("playlistfile","http://www.wernermn.com/assets/videos/playlists/<span class="ajaxSearch_highlight ajaxSearch_highlight1">eaton</span>.xml");
      so.addVariable("playlist","bottom");
      so.addParam("allowfullscreen","true");
      so.addParam("allowscriptaccess","always");
      so.addParam("wmode","opaque");
      so.addVariable("backcolor","dedede");
      so.addVariable("frontcolor","004b8d");
      so.addVariable("lightcolor","555555");
      so.addVariable("screencolor","000000");
      so.addVariable("autostart","true");
      so.addVariable("repeat","list");
      so.write("mediaspace");
    </script>
    


    You can see on Line #3 the code that it’s inserting into my snippet. Is there any way to protect my snippet from being mis-rendered by other snippets? Thanks!
      • 5811
      • 1,717 Posts
      I suppose that this issue comes from after searching the term eaton? Is it true ?

      Not sure that is it the solution but ... With ajaxSearch you have 2 highlighting plugins.

      - the classical plugin.searchHighlight.tpl
      - and the advanced plugin.advSearchHighlight.tpl.

      With the classical, you search the terms to highlight between <body> and </body>.

      With the advanced, you define tags <!--start highlight--> and <!--end highlight--> to frame a piece of text to highlight. You could define as many pairs of tags you want. So you probably could set:
      <body><!--start highlight-->
      
      ...
      
      <!--end highlight--></body> 
      in your template.

      And in your snippet code.
      <!--end highlight-->
      
      You snippet
      
      <!--start highlight-->
      Try it. I haven’t tested it but this shoud work it.