[support] Unserializing Data for Use in a View

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


Christopher and all,

"from a coder to a non-coder"

I could blog on that formulation...

How about, "from an experienced coder to a novice coder"

or

"from a full-time coder to a part-time coder"

By the way, I'm not insulted or angry by your formulation, just taking note
of it and also trying to figure out my place in the world.

I think part of the liberation of open source and Drupal in particular is
that there is really a place for me, someone who doesn't want to code all
day, someone who wants to work with clients on site content, not just site
code. But my willingness to dabble in code and learn modest coding skills
and coding best practices is key to my participation in the Drupal community
and I think it offers great value to my clients. Sometimes it can be a bit
daunting to be in the midst of full-time coders who "get-it" at a far deeper
level.

As for dpm()... I don't love it. What I like about print_r is that it
reminds of the syntax (array keys in brackets) that I'll need to call the
information back out. But certainly the clear hierarchical structure of
dmp() can be really helpful.

@Steve Kessler... Since I'm not otherwise using uc_views it seems like a bit
of overkill when this solution is two short lines of code in a single .tpl
file.

Shai

On Fri, Sep 3, 2010 at 9:25 AM, Christopher M. Jones <cjones at partialflow.com
> wrote:

> 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/ ]
> >
> >
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20100903/76ddd931/attachment.html 


More information about the support mailing list