This module is Awesome. I was able to show node teasers in search results.
I want to highlight the searched terms in the teaser may be using search_excerpt (http://api.drupal.org/api/drupal/modules--search--search.module/function...)
Where & how to do this?

CommentFileSizeAuthor
#2 d7-search.PNG23.03 KBtechnikh

Comments

swentel’s picture

Status: Active » Postponed (maintainer needs more info)

Well, there's an option on the search configuration settings of ds (at admin/structure/ds/search) to highlight words in the text that is displayed. The search_excerpt function is not an option right now, but maybe we should create a field called 'search_excerpt' which does the same as the default search. If the first is good enough, I'll leave it as this, but I'm willing to investigate that extra field though.

technikh’s picture

StatusFileSize
new23.03 KB

I have that option checked but yet the search terms are not highlighted. You can see it here. http://relay7.technikh.com/?q=search/content/films
See the attached snapshot of my search settings.
In the page source I see that the javascript is loaded and when I uncheck that option it's not loaded.

<script type="text/javascript" src="http://relay7.technikh.com/sites/all/modules/ds/modules/ds_search/ds_search.js?loi8yd"></script>

do You think my jquery has some conflicts or is it the problem with my settings?

swentel’s picture

Aah, you are using the teaser version of it seems for search results. You'll have to change the 'HTML selector' to something like .node-teaser so the javascrit kicks in. Can you check if that makes it work ? Maybe I'll need to update the descriptions a bit on the settings page to make this clear.

technikh’s picture

Perfect. It worked. http://relay7.technikh.com/?q=search/content/film Thanks.
How Can we do this in PHP instead of javascript? because in this case http://relay7.technikh.com/?q=search/content/swiss
I want to show extra information for the searched terms. like when I search for "swiss" which is a taxonomy term with fields, I want to show other field information of that particular taxonomy term

I was looking at search hooks like http://api.drupal.org/api/drupal/modules--node--node.api.php/function/ho... but didn't know where & how to use it

If my module can read the searched terms, I can manipulate & display the node teaser accordingly.

Any suggestions?

swentel’s picture

Can't you just add more fields in the search result view mode ?

technikh’s picture

I only want to show extra field information for searched terms. not all terms of the node.
because there may be like 100 terms to the node and if I show all field information for all terms the search result would be too long.
for this purpose my module needs to know the terms user searched for.

swentel’s picture

Status: Postponed (maintainer needs more info) » Fixed

One way todo this is using php and implementing hook_ds_fields_info() which enables you to create a field which content can be anything. The field will show up on Field UI to put into one of the regions of your layout. Look into ds.api.php for the function signature or into ds.ds_fields_info.inc for examples. The content can be a function which gets a lot of info in the function (field definition and the complete entity) and you can read the search term from the url (normally arg(2)) and you can do whatever PHP code in there to return the content you want. That's the easiest way to get the result you want I think.

technikh’s picture

I see. didn't thought of that "search term from the url". Thanks. that will work for me.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dadderley’s picture

@swentel
Thanks for the tip.

Also, thanks for the whole Display Suite module.
It is pretty awesome.