We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19986
    • 90 Posts
    I’ve added support for access control, i.e. hide private documents if the user doesn’t have permission to view them. The display of content extracts makes it particularly important to prevent private documents being listed to those without permission to view them.

    See http://modxcms.com/forums/index.php/topic,4247.0.html.

    Steph
      • 6726
      • 7,075 Posts
      Thanks Marc for this great modification of the FlexSearchForm !

      Just a question while I am here : could the snippet be made to also highlight search terms on the page content ?
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 17883
        • 1,039 Posts
        Hi David,

        Just a question while I am here : could the snippet be made to also highlight search terms on the page content ?

        You mean after clicking on a search result link? Should be possible with a plugin. On the search result page the terms are added to the URL and then fetched by a plugin after/before page rendering... Don´t have time this week, but I keep it in mind or perhaps someone else can... wink What I also want to realise is a kind of weighting the results (like in this forum) and displaying in percent or with stars or whatever. For example a text with 1000 words has one match of the search term -> 1 star. 2 matches -> 2 stars and so on. Matches in titles are more important etc. Just need a good algorithm wink
          • 6726
          • 7,075 Posts
          In fact, I found something about that : Susan wrote such a plugin for highlighting the search terms on the document, but there are some issues : it broke my pages when the html code contains the search term, it get wrapped in a span with some disatrous effects sad

          Edit : Dumb me, the issue has been fixed !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 36451
            • 264 Posts
            Thank you, modxers! With one small addition this is the perfect search script for me.

            Due to the international flavour wink of my recent project I’ve added 4 lines of code to this snippet, that I borrowed from xyzvisual (see http://modxcms.com/forums/index.php/topic,1254.0.html for details). This transformes the search string to handle the german umlaute.
            The changes: Search for "// CONFIGURE " (without quotation marks) and replace this with
            // CONFIGURE
            
            // Multilanguage Hack by xyzvizual
            // see http://modxcms.com/forums/index.php/topic,1254.msg16206.html#msg16206
            // if you need other character update this arrays
            $umlaute = array("ä","ö","ü","Ä","Ö","Ü","&","ß");
            $replace = array("ä","ö","ü","Ä","Ö","Ü","&","ß");
            then do a search for "// End cleansing search string" and add the second part:
            } // End cleansing search string
            
            
            // Multilanguage search
            $searchString = str_replace($umlaute, $replace, $searchString);
            
            That does the job for me. Maybe other people find it useful.
              • 27
              • 117 Posts
              Hi all

              I get the search term highlighted in
               x results found for "blah ".


              but not in the results list, the "<span class="FSF_highlight1"> </span>" wrapper is missing, is anyone else getting that?

              I am getting the highlight working in the truncated text content, but not in pagetitles or (linked) titles. Thats cool, I’m happy with that!

              Excellent snippet - thanks a million

              0