Hi, I would like to retrieve a views data and display it in a computed field but I've not had much luck with views_embed_view.

How can I go about it?

Comments

Mark Nielsen’s picture

Here's what I did, randomuser. The machine name of my view is "service_enquiry". It's a view which shows the titles of all nodes which the user has currently flagged, as items in an HTML list.

This is all I have in the Computed Code field of my computed field.

$node_field[0]['value'] = views_embed_view('service_enquiry', 'default');

For this field, I have set it to store the value in the database, in text format.

In the Display Format field, I have:

$display = $node_field_item['value'];

After reading your request back there, I resolved to contribute a handbook page with the recipe for my enquiry system. I haven't had the time to do this just yet, but I hope the above helps you in the meantime.