21310 Posts in 5739 Topics by 2604 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 794 Views |
-
Multiple Break Tags in Search Results

11 May 2011 at 11:59pm
Hi all,
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?
Thanks,
Lee -
Re: Multiple Break Tags in Search Results

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);
-
Re: Multiple Break Tags in Search Results

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.
Lee
| 794 Views | ||
|
Page:
1
|
Go to Top |

