Is there any way to add a span tag or something similar to the search results? By words I'm refering to the words that are entered into the textfield and when the results are displayed the keywords are in bold or something... Similar to the way core search does it.
Comments
Comment #1
dawehnerMh you could use theming of the view itself and calling in preprocess_views_view
function search_excerpt($keys, $text); on the rows.
I think you have to read out $keys out of $vars, but i'm not sure how to do it.
Comment #2
garyh commentedHi,
Also looking for this solution. Want to mimic the core search results with searching content via an exposed filter.
Example: if a user searches for "String" i'd like the output to come back as
Lorem ipsum blah blah
<span> String </span>lorum blah text...Gary
Comment #3
savageanne commentedI would also like this. Did either of you have any luck?
Comment #4
merlinofchaos commentedI think there's already another issue about this, but leaving it open. If someone feels like duplicate hunting, that would be nice.
There was an aborted attempt to write a style that would emulate core search. That was never completed however (but some of the aborted code is actually still in Views; it went in during the initial search implementation). We would need a volunteer to fix this up.
Comment #5
ptitb commentedI found a solution and I think it's the duplicate merlinofchaos meant.
You can find it at: http://drupal.org/node/488466
This solution also works for me.
Comment #6
dawehnerthx
Comment #7
entrigan commentedto expand on solution from #1,
probably the easiest way to implement this is create a template file in your theme for your "body" field views-view-fields--my-view--body.tpl.php then in the template would go something like:
print search_excerpt($view->exposed_data['keys'], $output);Comment #8
bshaddad commentedGreat, thanks for the solution.
All what I had to do is to replace the "keys" word with the name of the field:
Comment #9
walker2238 commented