I'm creating a view of ubercart order products. I got the necessary data to be accessible to Views using Table Wizard (http://drupal.org/project/tw).
The product attribute info is stored serialized in the "data" field on the uc_order_products table. Here is an example of the raw serialized data:
a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"attributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Jane
Doe, John Doe";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Smith and Sandy Smith";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95333579";}
I have no problem printing it out like above.
Unserialized it looks like this:
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 )
I want to print out: Jane Doe, John Doe
Here is what views-view-field.tpl.php has to say:
// $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /** * This template is used to print a single field in a view. It is not * actually used in default Views, as this is registered as a theme * function which has better performance. For single overrides, the * template is perfectly okay. * * Variables available: * - $view: The view object * - $field: The field handler object that can process the input * - $row: The raw SQL result that can be used * - $output: The processed output that will normally be used. * * When fetching output from the $row, this construct should be used: * $data = $row->{$field->field_alias} * * The above will guarantee that you'll always get the correct data, * regardless of any changes in the aliasing that might happen if * the view is modified. */
This is what I'm putting in views-view-field.tpl.php:
$data = unserialize($output); print $data['Attending'][0];
Nothing gets returned.
What am I doing wrong?
thanks,
Shai
I'm not an expert here, but I'm reading the coments differently than you are.
I think you should be working with $row->data ( or at least $row) and not with $output. That's got html in it, right?
Dave
________________________________
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shai Gluskin Sent: Thursday, September 02, 2010 1:24 PM To: support@drupal.org Subject: [support] Unserializing Data for Use in a View
I'm creating a view of ubercart order products. I got the necessary data to be accessible to Views using Table Wizard (http://drupal.org/project/tw).
The product attribute info is stored serialized in the "data" field on the uc_order_products table. Here is an example of the raw serialized data:
a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"att ributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Jane Doe, John Doe";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Smith and Sandy Smith";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95 333579";}
I have no problem printing it out like above.
Unserialized it looks like this:
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 )
I want to print out: Jane Doe, John Doe
Here is what views-view-field.tpl.php has to say:
// $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /** * This template is used to print a single field in a view. It is not * actually used in default Views, as this is registered as a theme * function which has better performance. For single overrides, the * template is perfectly okay. * * Variables available: * - $view: The view object * - $field: The field handler object that can process the input * - $row: The raw SQL result that can be used * - $output: The processed output that will normally be used. * * When fetching output from the $row, this construct should be used: * $data = $row->{$field->field_alias} * * The above will guarantee that you'll always get the correct data, * regardless of any changes in the aliasing that might happen if * the view is modified. */
This is what I'm putting in views-view-field.tpl.php:
$data = unserialize($output); print $data['Attending'][0];
Nothing gets returned.
What am I doing wrong?
thanks,
Shai
David and all,
David, thanks for the response:
I just tried
$orderattributes = $row->{$field->data}; print $orderattributes;
I get a php fatal error: "Cannot access empty property"
The following is from Views "Theme information": Field uc_order_products: data (ID: data)
Ideas?
Thanks much,
Shai
On Thu, Sep 2, 2010 at 4:31 PM, Metzler, David metzlerd@evergreen.eduwrote:
I'm not an expert here, but I'm reading the coments differently than you are.
I think you should be working with $row->data ( or at least $row) and not with $output. That's got html in it, right?
Dave
*From:* support-bounces@drupal.org [mailto:support-bounces@drupal.org] *On Behalf Of *Shai Gluskin *Sent:* Thursday, September 02, 2010 1:24 PM *To:* support@drupal.org *Subject:* [support] Unserializing Data for Use in a View
I'm creating a view of ubercart order products. I got the necessary data to be accessible to Views using Table Wizard (http://drupal.org/project/tw).
The product attribute info is stored serialized in the "data" field on the uc_order_products table. Here is an example of the raw serialized data:
a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"attributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Jane
Doe, John Doe";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Smith and Sandy Smith";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95333579";}
I have no problem printing it out like above.
Unserialized it looks like this:
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 )
I want to print out: Jane Doe, John Doe
Here is what views-view-field.tpl.php has to say:
// $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /**
- This template is used to print a single field in a view. It is not
- actually used in default Views, as this is registered as a theme
- function which has better performance. For single overrides, the
- template is perfectly okay.
- Variables available:
- $view: The view object
- $field: The field handler object that can process the input
- $row: The raw SQL result that can be used
- $output: The processed output that will normally be used.
- When fetching output from the $row, this construct should be used:
- $data = $row->{$field->field_alias}
- The above will guarantee that you'll always get the correct data,
- regardless of any changes in the aliasing that might happen if
- the view is modified.
*/
This is what I'm putting in views-view-field.tpl.php:
$data = unserialize($output); print $data['Attending'][0];
Nothing gets returned.
What am I doing wrong?
thanks,
Shai
-- [ Drupal support list | http://lists.drupal.org/ ]
Try changing this to this to see what the properties really are. If you don't understand what you get there, then tell me the results, and I'll try and interpret them for you.
$orderattributes = print_r($row,1); print $orderattributes;
________________________________
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shai Gluskin Sent: Thursday, September 02, 2010 2:01 PM To: support@drupal.org Subject: Re: [support] Unserializing Data for Use in a View
David and all,
David, thanks for the response:
I just tried
$orderattributes = $row->{$field->data}; print $orderattributes;
I get a php fatal error: "Cannot access empty property"
The following is from Views "Theme information": Field uc_order_products: data (ID: data)
Ideas?
Thanks much,
Shai
On Thu, Sep 2, 2010 at 4:31 PM, Metzler, David metzlerd@evergreen.edu wrote:
I'm not an expert here, but I'm reading the coments differently than you are. I think you should be working with $row->data ( or at least $row) and not with $output. That's got html in it, right? Dave
________________________________
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shai Gluskin Sent: Thursday, September 02, 2010 1:24 PM To: support@drupal.org Subject: [support] Unserializing Data for Use in a View I'm creating a view of ubercart order products. I got the necessary data to be accessible to Views using Table Wizard (http://drupal.org/project/tw).
The product attribute info is stored serialized in the "data" field on the uc_order_products table. Here is an example of the raw serialized data:
a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"att ributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Jane Doe, John Doe";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Smith and Sandy Smith";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95 333579";}
I have no problem printing it out like above.
Unserialized it looks like this:
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 ) I want to print out: Jane Doe, John Doe Here is what views-view-field.tpl.php has to say: // $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /** * This template is used to print a single field in a view. It is not * actually used in default Views, as this is registered as a theme * function which has better performance. For single overrides, the * template is perfectly okay. * * Variables available: * - $view: The view object * - $field: The field handler object that can process the input * - $row: The raw SQL result that can be used * - $output: The processed output that will normally be used. * * When fetching output from the $row, this construct should be used: * $data = $row->{$field->field_alias} * * The above will guarantee that you'll always get the correct data, * regardless of any changes in the aliasing that might happen if * the view is modified. */ This is what I'm putting in views-view-field.tpl.php: $data = unserialize($output); print $data['Attending'][0];
Nothing gets returned.
What am I doing wrong?
thanks,
Shai
-- [ Drupal support list | http://lists.drupal.org/ ]
Hi Dave,
Thanks so much, this is what prints out, following your instructions. the yellow part is the part that I'm interested in:
stdClass Object ( [order_product_id] => 65 [uc_order_products_qty] => 2 [uc_order_products_title] => Rosh Hashanah Day 1 [uc_orders_billing_last_name] => Eizen [uc_order_products_data] => a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"attributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Irene Eizen, Bernard Eizen";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Sack and Sandy Steiker";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95333579";} [uc_order_products_nid] => 565 )
Shai
On Thu, Sep 2, 2010 at 7:22 PM, Metzler, David metzlerd@evergreen.eduwrote:
Try changing this to this to see what the properties really are. If you don't understand what you get there, then tell me the results, and I'll try and interpret them for you.
$orderattributes = print_r($row,1); print $orderattributes;
*From:* support-bounces@drupal.org [mailto:support-bounces@drupal.org] *On Behalf Of *Shai Gluskin *Sent:* Thursday, September 02, 2010 2:01 PM *To:* support@drupal.org *Subject:* Re: [support] Unserializing Data for Use in a View
David and all,
David, thanks for the response:
I just tried
$orderattributes = $row->{$field->data}; print $orderattributes;
I get a php fatal error: "Cannot access empty property"
The following is from Views "Theme information": Field uc_order_products: data (ID: data)
Ideas?
Thanks much,
Shai
On Thu, Sep 2, 2010 at 4:31 PM, Metzler, David metzlerd@evergreen.eduwrote:
I'm not an expert here, but I'm reading the coments differently than you are.
I think you should be working with $row->data ( or at least $row) and not with $output. That's got html in it, right?
Dave
*From:* support-bounces@drupal.org [mailto:support-bounces@drupal.org] *On Behalf Of *Shai Gluskin *Sent:* Thursday, September 02, 2010 1:24 PM *To:* support@drupal.org *Subject:* [support] Unserializing Data for Use in a View
I'm creating a view of ubercart order products. I got the necessary data to be accessible to Views using Table Wizard ( http://drupal.org/project/tw).
The product attribute info is stored serialized in the "data" field on the uc_order_products table. Here is an example of the raw serialized data:
a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"attributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Jane
Doe, John Doe";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Smith and Sandy Smith";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95333579";}
I have no problem printing it out like above.
Unserialized it looks like this:
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 )
I want to print out: Jane Doe, John Doe
Here is what views-view-field.tpl.php has to say:
// $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /**
- This template is used to print a single field in a view. It is not
- actually used in default Views, as this is registered as a theme
- function which has better performance. For single overrides, the
- template is perfectly okay.
- Variables available:
- $view: The view object
- $field: The field handler object that can process the input
- $row: The raw SQL result that can be used
- $output: The processed output that will normally be used.
- When fetching output from the $row, this construct should be used:
- $data = $row->{$field->field_alias}
- The above will guarantee that you'll always get the correct data,
- regardless of any changes in the aliasing that might happen if
- the view is modified.
*/
This is what I'm putting in views-view-field.tpl.php:
$data = unserialize($output); print $data['Attending'][0];
Nothing gets returned.
What am I doing wrong?
thanks,
Shai
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
try
$orderattributes = unserialize($row->order_product_data); // Get a sense of the structure here print_r($orderattributes); // Try and get a specific value if I'm reading it right print $orderattributes['kit_id'] .' - '. $order_attirbutes['module'];
Hope that helps.
________________________________
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shai Gluskin Sent: Thursday, September 02, 2010 4:47 PM To: support@drupal.org Subject: Re: [support] Unserializing Data for Use in a View
Hi Dave,
Thanks so much, this is what prints out, following your instructions. the yellow part is the part that I'm interested in:
stdClass Object ( [order_product_id] => 65 [uc_order_products_qty] => 2 [uc_order_products_title] => Rosh Hashanah Day 1 [uc_orders_billing_last_name] => Eizen [uc_order_products_data] => a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"att ributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Irene Eizen, Bernard Eizen";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Sack and Sandy Steiker";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7. 95333579";} [uc_order_products_nid] => 565 )
Shai
On Thu, Sep 2, 2010 at 7:22 PM, Metzler, David metzlerd@evergreen.edu wrote:
Try changing this to this to see what the properties really are. If you don't understand what you get there, then tell me the results, and I'll try and interpret them for you. $orderattributes = print_r($row,1); print $orderattributes; ________________________________
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shai Gluskin Sent: Thursday, September 02, 2010 2:01 PM To: support@drupal.org Subject: Re: [support] Unserializing Data for Use in a View David and all,
David, thanks for the response:
I just tried
$orderattributes = $row->{$field->data}; print $orderattributes;
I get a php fatal error: "Cannot access empty property" The following is from Views "Theme information": Field uc_order_products: data (ID: data)
Ideas?
Thanks much,
Shai
On Thu, Sep 2, 2010 at 4:31 PM, Metzler, David metzlerd@evergreen.edu wrote:
I'm not an expert here, but I'm reading the coments differently than you are. I think you should be working with $row->data ( or at least $row) and not with $output. That's got html in it, right? Dave
________________________________
From: support-bounces@drupal.org [mailto:support-bounces@drupal.org] On Behalf Of Shai Gluskin Sent: Thursday, September 02, 2010 1:24 PM To: support@drupal.org Subject: [support] Unserializing Data for Use in a View I'm creating a view of ubercart order products. I got the necessary data to be accessible to Views using Table Wizard (http://drupal.org/project/tw).
The product attribute info is stored serialized in the "data" field on the uc_order_products table. Here is an example of the raw serialized data:
a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"att ributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Jane Doe, John Doe";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Smith and Sandy Smith";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95 333579";}
I have no problem printing it out like above.
Unserialized it looks like this:
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 ) I want to print out: Jane Doe, John Doe Here is what views-view-field.tpl.php has to say: // $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /** * This template is used to print a single field in a view. It is not * actually used in default Views, as this is registered as a theme * function which has better performance. For single overrides, the * template is perfectly okay. * * Variables available: * - $view: The view object * - $field: The field handler object that can process the input * - $row: The raw SQL result that can be used * - $output: The processed output that will normally be used. * * When fetching output from the $row, this construct should be used: * $data = $row->{$field->field_alias} * * The above will guarantee that you'll always get the correct data, * regardless of any changes in the aliasing that might happen if * the view is modified. */ This is what I'm putting in views-view-field.tpl.php: $data = unserialize($output); print $data['Attending'][0];
Nothing gets returned.
What am I doing wrong?
thanks,
Shai
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
Hi Dave and all,
Thanks so much. I figured it out.
Here is the answer:
$data = unserialize($row->{$field->field_alias}); print $data[attributes][Attending][0];
Here was one prior step prior that made things easy:
$data = unserialize($row->{$field->field_alias}); echo '<pre>'; print_r ($data); echo '</pre>';
But as someone who is fairly new to programming... and I'm basically a site-builder, I code on an as-needed basis... not all day long -- let me just rant about something in coding documentation that drives me nuts! There are no conventions when presenting examples about what is literal and what I should fill in with an item specific to my situation. I can't tell you how many other things I tried before I finally saw an example of "$row->{$field->field_alias} being used and AHA --- It's literal, I copy as is; I'm not supposed to change anything. I think this is the biggest challenge to people learning programming.
Dave thanks SOOOO much, you really helped.
Shai
On Thu, Sep 2, 2010 at 7:46 PM, Shai Gluskin shai@content2zero.com wrote:
Hi Dave,
Thanks so much, this is what prints out, following your instructions. the yellow part is the part that I'm interested in:
stdClass Object ( [order_product_id] => 65 [uc_order_products_qty] => 2 [uc_order_products_title] => Rosh Hashanah Day 1 [uc_orders_billing_last_name] => Eizen [uc_order_products_data] => a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"attributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Irene Eizen, Bernard Eizen";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Sack and Sandy Steiker";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95333579";} [uc_order_products_nid] => 565 )
Shai
On Thu, Sep 2, 2010 at 7:22 PM, Metzler, David metzlerd@evergreen.eduwrote:
Try changing this to this to see what the properties really are. If you don't understand what you get there, then tell me the results, and I'll try and interpret them for you.
$orderattributes = print_r($row,1); print $orderattributes;
*From:* support-bounces@drupal.org [mailto:support-bounces@drupal.org] *On Behalf Of *Shai Gluskin *Sent:* Thursday, September 02, 2010 2:01 PM *To:* support@drupal.org *Subject:* Re: [support] Unserializing Data for Use in a View
David and all,
David, thanks for the response:
I just tried
$orderattributes = $row->{$field->data}; print $orderattributes;
I get a php fatal error: "Cannot access empty property"
The following is from Views "Theme information": Field uc_order_products: data (ID: data)
Ideas?
Thanks much,
Shai
On Thu, Sep 2, 2010 at 4:31 PM, Metzler, David metzlerd@evergreen.eduwrote:
I'm not an expert here, but I'm reading the coments differently than you are.
I think you should be working with $row->data ( or at least $row) and not with $output. That's got html in it, right?
Dave
*From:* support-bounces@drupal.org [mailto:support-bounces@drupal.org] *On Behalf Of *Shai Gluskin *Sent:* Thursday, September 02, 2010 1:24 PM *To:* support@drupal.org *Subject:* [support] Unserializing Data for Use in a View
I'm creating a view of ubercart order products. I got the necessary data to be accessible to Views using Table Wizard ( http://drupal.org/project/tw).
The product attribute info is stored serialized in the "data" field on the uc_order_products table. Here is an example of the raw serialized data:
a:5:{s:6:"kit_id";s:3:"570";s:6:"module";s:14:"uc_product_kit";s:10:"attributes";a:2:{s:9:"Attending";a:1:{i:0;s:26:"Jane
Doe, John Doe";}s:4:"Note";a:1:{i:0;s:45:"We are friends of Eric Smith and Sandy Smith";}}s:9:"shippable";s:1:"0";s:9:"unique_id";s:23:"4c7d632a8090c7.95333579";}
I have no problem printing it out like above.
Unserialized it looks like this:
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 )
I want to print out: Jane Doe, John Doe
Here is what views-view-field.tpl.php has to say:
// $Id: views-view-field.tpl.php,v 1.1 2008/05/16 22:22:32 merlinofchaos Exp $ /**
- This template is used to print a single field in a view. It is not
- actually used in default Views, as this is registered as a theme
- function which has better performance. For single overrides, the
- template is perfectly okay.
- Variables available:
- $view: The view object
- $field: The field handler object that can process the input
- $row: The raw SQL result that can be used
- $output: The processed output that will normally be used.
- When fetching output from the $row, this construct should be used:
- $data = $row->{$field->field_alias}
- The above will guarantee that you'll always get the correct data,
- regardless of any changes in the aliasing that might happen if
- the view is modified.
*/
This is what I'm putting in views-view-field.tpl.php:
$data = unserialize($output); print $data['Attending'][0];
Nothing gets returned.
What am I doing wrong?
thanks,
Shai
-- [ Drupal support list | http://lists.drupal.org/ ]
-- [ Drupal support list | http://lists.drupal.org/ ]
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
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@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/ ]
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@gmail.com mailto:imaaxa@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/ ]
I may be missing something here but could this not be done with http://drupal.org/project/uc_views and a Global Rewrite.
On Fri, Sep 3, 2010 at 3:25 PM, Christopher M. Jones <cjones@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@gmail.com mailto:imaaxa@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/ ]
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@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@gmail.com mailto:imaaxa@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/ ]
OK. Read your past note quickly. Thought you declared yourself a non coder. No big. And re dpm(), suggestions are meant to be taken or left. Just thought you might not know about the tool. There was a time when I didn't.
On 09/03/2010 10:14 AM, Shai Gluskin wrote:
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@partialflow.com mailto:cjones@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@gmail.com <mailto:imaaxa@gmail.com> > <mailto:imaaxa@gmail.com <mailto:imaaxa@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/ ]