23552 Posts in 19349 Topics by 2891 members
|Go to End|
11 May 2011 at 11:59pm
In my current SilverStripe project, I'm using the search features to return content items from the site pages. These items have images, which the search strips out, which is good. However, where the images were, I'm left with multiple <br /> tags, so the results is shown with large gaps. Is there an easy way to remove extra break tags or perhaps compress them to a single break?
14 May 2011 at 8:09pm
Anyone have any ideas?
15 May 2011 at 5:58am
Maybe something like this simple testcase will help (I'm no regexpert):
$searchResult = 'aaaaaa<br />bbbbbbbb<br /><br />cccc';
$pattern = '@(<br( /)*\>)+@i';
$replacement = ''; //or use $replacement = '<br />';
searchResult = preg_replace($pattern, $replacement, $searchResult);
16 May 2011 at 9:34pm
Thank you. I was hoping there would be a simple method I could override or a switch of some sort. There's obviously a method somewhere that strips out the images, so there must be a way to hijack that so that the output could be massaged.
|Go to Top|