I am trying to expose the {system} table to views as part of the Enabled Modules module.

However, the field "info", which has the most useful information contained is serialized. Is there a particular way that this should be handled?

Comments

dawehner’s picture

Sure you cannot write a filter for it. But you could write a abstract field handler which just unserialized the value of the field. Thats more or less trivial to write.

juliangb’s picture

Thanks for your reply.

In this case, the serialized data is an array. So I guess it is easy to do some processing to take one value from that array, but is there any way that this data could be split out into individual fields?

merlinofchaos’s picture

Status: Active » Fixed

Yes, as fields that is fairly trivial. Fields that are simply rendering data do not have to correspond directly to real fields at all -- you can simply set 'real field' to info to have it add the correct field. Then you'll need to set up the render() method in the object to unpack the data and render the right portion of the data. Once you've done it once you'll be able to duplicate this easily for everything else.

In contrast, sorting and filtering on this data is incredibly difficult. It's technically doable, but it's not recommended as it is a nightmare, both in terms of difficulty and performance.

juliangb’s picture

Thanks again for the assistance here.

Just to let people know what I ended up doing, is since it was obviously going be difficult to do the trickery within views, I've created a db table which duplicates that field, except separated out into separate fields. That way, I can just plug it into views as a normal field. My table gets updated whenever the {system} table itself gets updated via hook_system_info_alter.

Status: Fixed » Closed (fixed)

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

supriyarajgopal’s picture

Version: 6.x-2.8 » 7.x-3.14
Issue summary: View changes
Status: Closed (fixed) » Active

Hi,

I have the exact same requirement.

Can somebody please post a code snippet explaining how to expose the serialized data as individual fields in Views?

Edit:

I exposed the serialized field in hook_views_data() and set the field handler to 'views_handler_field_serialized'.
In the Views Fields section, I added the serialized field and chose the 'Display format' as 'A certain key' which allowed me to expose specific serialized values.

Hope this helps someone.

Regards,
Supriya Rajgopal

supriyarajgopal’s picture

Status: Active » Closed (fixed)