I'm not sure if this is the right place to post this but...

I've altered the output of the body field on a custom module using hook_node_view, and when the node is displayed the output is as expected.

However, when views returns this field the body doesn't have my changed output. The hook isn't called.

Does anyone have any ideas how I can change the output when it's passed to views.

Thanks,

David

CommentFileSizeAuthor
#1 rewrite_results.jpg165.18 KBsrebelo

Comments

srebelo’s picture

StatusFileSize
new165.18 KB

Hi David,

The hook_node_view will only modify the node page. A view is not a node display.

All view fields have a "REWRITE RESULTS" option (see image attached) where you can rewrite the field by adding other fields available in the view (look at the "REPLACEMENT PATTERNS") or just modifying the field itself.

Hope this helps!

dubs’s picture

Thanks srebelo.

That explains why it isn't being called. I'm pretty sure hook_nodeapi($op = view) was called before as this is a port from D6 to D7 which is why I expected it to work here.

The solution you suggested wouldn't work in my case unfortunately because the module is the only source for the changed output. I could use a PHP custom field in Views to do this and pull the data from the module though and that would work.

I guess the question would be more along the lines of is there a hook_field_view function or something like that which would allow field values to be changed by modules before they are called by views?

kars-t’s picture

Status: Active » Fixed

Hi

I am closing this issue to clean up the issue queue. Feel free to reopen the issue if there is new information and the problem still resides. If not please make sure you close your issues that you don't need any more.

Maybe you can get support from the local user group. Please take a look at this list at groups.drupal.org.

Status: Fixed » Closed (fixed)

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