Closed (fixed)
Project:
Views (for Drupal 7)
Version:
7.x-3.14
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Apr 2010 at 14:38 UTC
Updated:
3 Aug 2016 at 12:50 UTC
Jump to comment: Most recent
Comments
Comment #1
dawehnerSure 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.
Comment #2
juliangb commentedThanks 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?
Comment #3
merlinofchaos commentedYes, 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.
Comment #4
juliangb commentedThanks 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.
Comment #6
supriyarajgopal commentedHi,
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
Comment #7
supriyarajgopal commented