<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Page comments</title>
		<link>http://www.ssbits.com/home/</link>
		<atom:link href="http://www.ssbits.com/home/" rel="self" type="application/rss+xml" />
		<description></description>

		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_1975</link>
			<description>I tried using this technique in a project recently, but I found that it didn't render the returning html. It would output the text &lt;span class=&quot;highlight&quot;&gt;&lt;/span&gt; (And I've noticed the same thing happens on the Silverstripe forums).
Does anyone know how to make it render the html instead of printing it? I'd really like to use this bit of functionality!</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_1975</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_1279</link>
			<description>I used something like that (from SS forum): 

function MyContextSummary($characters = 500, $string = false, $striphtml = true, $highlight = true) {

        if (!$string)
            $string = $_REQUEST['Search']; // Use the default &quot;Search&quot; request variable (from SearchForm)

        /*         * * Prepare Content ** */

        // Replace &lt;br /&gt; in order to get separate words

        $content = str_replace('&lt;br /&gt;', ' ', $this-&gt;Content);

        // Decoding entities prevents XML validation error

        $content = html_entity_decode($content, ENT_COMPAT, 'UTF-8');

        // Remove HTML tags so we don't have to deal with matching tags

        $text = strip_tags($content);

        // Remove BBCode

        $pattern = '|[[\/\!]*?[^\[\]]*?]|si';

        $replace = '';

        $text = preg_replace($pattern, $replace, $text);

        // Find the search string

        $position = (int) stripos($text, $string);

        // We want the search string to be in the middle of our block to give it some context

        $position = max(0, $position - ($characters / 2));

        // We don't want to start mid-word

        if ($position &gt; 0) {

            $position = max((int) strrpos(substr($text, 0, $position), ' '), (int) strrpos(substr($text, 0, $position), &quot;\n&quot;));
        }

        $summary = substr($text, $position, $characters);

        // We also don't want to end mid-word 
        $offset = $characters + $position;
        if ($offset &gt; strlen($text) - 1)
            $offset = strlen($text) - 1;
        $position = min((int) strpos($text, ' ', $offset), (int) strpos($text, &quot;\n&quot;, $offset));
        if ($position)
            $summary = $summary . substr($text, $offset, $position - $offset);

        if ($highlight) {
            // Setting the content taht will be inserted before and after the highlighted words 
            $before_content = &quot;&lt;span class=\&quot;highlight\&quot;&gt;&quot;;
            $after_content = &quot;&lt;/span&gt;&quot;;

            // Save the different search values into an array 
            $stringPieces = explode(' ', $string);

            foreach ($stringPieces as $stringPiece) {
                //Setting the start from where $stringPiece will be searched 
                $offset = 0;
                // Recursively add before_text and after_text around all found $stringPiece

                while ($position = stripos($summary, $stringPiece, $offset)) {
                    $summary =
                            substr($summary, 0, $position)
                            . $before_content
                            . substr($summary, $position, strlen($stringPiece))
                            . $after_content
                            . substr($summary, $position + strlen($stringPiece), strlen($summary) - ($position + 1));

                    $offset = $position + strlen($before_content) + strlen($after_content);
                }
            }
        }

        return trim($summary);
    }</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_1279</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_1217</link>
			<description>Mom,  I added the size I wanted when using the method in the .ss template - and it worked!

eg &lt;p&gt;$Content.ContextSummary(250)&lt;/p&gt;</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_1217</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_852</link>
			<description>Hi Mom,
You use the ContextSummary method in your .ss template as shown above in the first block of grey code.
Pete</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_852</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_851</link>
			<description>Hi, 

Where to put the function ContextSummary as I would like to limit the character in search results. 

Thanks
Bunheng</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_851</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_646</link>
			<description>Hi Matt,
Yes you are right!  I totally forgot that I had this function in the Page_Controller...

   function results($data, $form){
      $data = array(
      'Results' =&gt; $form-&gt;getResults(),
      'Query' =&gt; $form-&gt;getSearchQuery(),
      'Title' =&gt; 'Search Results'
      );
      $this-&gt;Query = $form-&gt;getSearchQuery();

      return $this-&gt;customise($data)-&gt;renderWith(array('Page_results', 'Page'));
   }

You can see here that I did just cut and paste the code from the tutorial which does set the Query property both directly and through the customize method.  Probably an unnecessary duplication.

Sorry about that!  Luckily the ContextSummary version works without this.</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_646</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_644</link>
			<description>Hi Pete,

From looking on the SS docs (http://doc.silverstripe.org/sapphire/en/tutorials/4-site-search#showing-the-results) it suggests defining; &quot;$this-&gt;Query = $form-&gt;getSearchQuery();&quot; Although Im not sure if that is right because I thought it would get overwritten by $this-&gt;customize() (in the example it seems to be duplicated).

Is that what you were doing?</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_644</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_641</link>
			<description>Hi Matt,
I got the Controller::curr()-&gt;Query returning a null value when nothing had been entered in the search box.
I did do a fair bit of searching around for this kind of functionality before I wrote thi and I had not found Text::ContextSummary.  From an initial glance it looks like this does do pretty much just what I wanted.
Thanks for pointing me in the right direction.  I think the documentation on this function is sorely lacking.  Hopefully this posting and your comment will help raise its profile.
Thanks again Matt.</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_641</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_640</link>
			<description>Controller::curr()-&gt;Query is returning a null value ?

Also Im not sure why you wouldn't just use the function from Text::ContextSummary() ?</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2011/pete-bacon-s-new-post-2/#PageComment_640</guid>
		</item>
		

	</channel>
</rss>