[support] Unserializing Data for Use in a View

Shai Gluskin shai at content2zero.com
Fri Sep 3 02:14:42 UTC 2010


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> 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/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20100902/b2ae6581/attachment.html 


More information about the support mailing list