[support] Unserializing Data for Use in a View

Christopher M. Jones cjones at partialflow.com
Fri Sep 3 13:25:54 UTC 2010


Just a tip, from a coder to a non coder. Install the devel module, and 
in stead of print_r() you can use dpm(), which outputs arrays using 
krumo. Much easier to read and understand.

Glad you figured it out.

On 09/02/2010 10:14 PM, Shai Gluskin wrote:
> Hi Cory,
>
> Thanks.  I think we were writing at the same time.
>
> Unserializing the $output won't work, because the $output comes with
> some other stuff, like html.
>
> What works is this:
>
> $data = unserialize($row->{$field->field_alias});
> print $data['attributes']['Attending'][0];
>
> To all, I apologize for not quoting the array keys in my previous "I got
> it" post.
>
> But thank you.
>
> I've posted an issue for documentation at the Views queue, suggesting a
> change in the explanatory text of views-view-field.tpl.php to be
> explicit that the snippet is literal.
>
> You can +1 or make alternative suggestions at:
> http://drupal.org/node/901088
>
> Shai
>
> On Thu, Sep 2, 2010 at 9:30 PM, Cory Gilliam <imaaxa at gmail.com
> <mailto:imaaxa at gmail.com>> wrote:
>
>
>     The data you are trying to get is inside an array that is inside an
>     array.
>
>
>     Array(
>        [kit_id] => 570
>        [module] => uc_product_kit
>        [attributes] => Array(
>          [Attending] => Array(
>            [0] => Jane Doe, John Doe
>          )
>          [Note] => Array(
>            [0] => We are friends of Eric Smith and Sandy Smith
>          )
>        )
>        [shippable] => 0
>        [unique_id] => 4c7d632a8090c7.95333579
>     )
>
>     You need to add the name of the array that this array is in.
>
>     $data = unserialize($output);
>     print $data ['attributes'] ['Attending'][0];
>
>     Little rusty at this.  Hope that helps.
>     Cory
>
>
>     --
>     [ Drupal support list | http://lists.drupal.org/ ]
>
>


More information about the support mailing list