How to alter node body content through Views pre render hook?

I have build the view to display node title and node body also I have applied combined fields filter which searches the keyword in title and body and returns the results.

While rendering the contents I have to render the title and body with the highlighted keywords that are been searched.

Currently I am using hook_views_pre_render to alter the same.But unable to replace the body text with my generated results.

How can I alter the body contents?

Drupal Answers Asked by pramodg on November 11, 2021

1 Answers

One Answer

What variable are you modifying? When I modify Views results I usually use hook_views_post_execute. I then modify the appropriate element in $view->result. You may be able to do the same from hook_views_pre_render (I don't use that one often especially in this type of case).

Answered by sareed on November 11, 2021

Add your own answers!

Related Questions

” a field on Manage display

1  Asked on February 6, 2021 by carrotandme


Display Entity Reference field twice, with different display modes

1  Asked on February 3, 2021 by paul-canning


Media html not rendering in blocks

1  Asked on February 3, 2021 by kristoffer-rom


How can I programmatically change the view mode?

4  Asked on February 3, 2021 by jmzea


How do I avoid API calls are cached?

2  Asked on February 2, 2021 by user1648228


Custom JSON api normalizer is not initiated

0  Asked on February 1, 2021 by kevinvhengst


Suddenly unable to add a field to a new content type

1  Asked on January 31, 2021 by leif


an error when changing the date form

1  Asked on January 30, 2021 by mahdi-alikhasi


Display content based on taxonomy with view

2  Asked on January 30, 2021


Why is my code called again written on build form?

0  Asked on January 29, 2021 by namit-garg


How to change path of taxonomy facet

1  Asked on January 24, 2021 by rahulkumar-it


Form field not show on Ajax Callback even the callback is called

1  Asked on January 23, 2021 by emad-karhely


Features to import content types

2  Asked on January 18, 2021 by webmaster-pf


Redirect user to previous page after registration

2  Asked on January 15, 2021 by lbogdan


Ask a Question

Get help from others!

© 2021 All rights reserved.