2

I want to change core search result snippet. I tried with preprocessor theme_preprocess_search_result(&$vars) but in $vars['result']['node'] there coming basic fields values and rendered content array. In my node, content is with paragraph bundles and field collections. I want to display one of my bundle value in search snippet.

$vars['result']['node'] values coming in array key 'rendered'

stdClass Object
(
    [vid] => 1039
    [uid] => 1
    [title] => What are the cut off times for funds transfers to an external bank?
    [log] => 
    [status] => 1
    [comment] => 0
    [promote] => 1
    [sticky] => 0
    [nid] => 235
    [type] => support
    [language] => und
    [created] => 1444988988
    [changed] => 1446531922
    [tnid] => 0
    [translate] => 0
    [revision_timestamp] => 1446531922
    [revision_uid] => 1
    [field_support_type_ref] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [tid] => 16
                            [taxonomy_term] => stdClass Object
                                (
                                    [tid] => 16
                                    [vid] => 4
                                    [name] => Internet Banking
                                    [description] => 
                                    [format] => filtered_html
                                    [weight] => 0
                                    [vocabulary_machine_name] => support_type
                                )

                        )

                )

        )

    [field_paragraph] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [value] => 1102
                            [revision_id] => 7916
                        )

                )

        )

    [name] => orangedigital
    [picture] => 0
    [data] => b:0;
    [workbench_access] => Array
        (
            [28] => 28
        )

    [entity_view_prepared] => 1
    [rendered] => 
Type: 
Internet Banking
Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. 

Lorem ipsum dolor sit amet. 

Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. 

)
0

You could build your own search result .tpl file inside your theme and take control over what displayed and the markup by creating a file named like search-results--[searchType].tpl.php After that you have to clear the cache in order to be recognized in theme registry

In your case you could limit the number of words displayed or divide based on empty line which mean a pragraph.

Take a look at D7 theme suggestions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.