Nice module. The php code runs however none of the values are available. The following is printed out:

Array
(
[args] =>
[field] =>
[row] =>
[rows] =>
[output] =>
[field_name] =>
[row_index] =>
)

(all blanks). The views formatted fields is the last field in the view. Am I doing something wrong? I am using the PHP Code input filter.

Comments

sidharth_k’s picture

The above is for PHP code...

return '<pre>'.print_r(array(
  'args' => $args,
  'field' => $field,
  'row' => $row,
  'rows' => $rows,
  'output' => $output,
  'field_name' => $field_name,
  'row_index' => $row_index,
), TRUE).'</pre>';
sidharth_k’s picture

Title: PHP code runs by values of variables not available » PHP code runs but values of variables not available
drawk’s picture

Same issue here.

peguca’s picture

Having the same issue here

Jackinloadup’s picture

Same here.. Subscribing

ibis’s picture

Same here.. Subscribing, but here is the previous version which support only PHP code ( http://drupal.org/node/441488#comment-1714722 ) and this work perfectly.

Gerald Mengisen’s picture

Same problem as above (no surprise); I had more luck with Views Custom Field once I read this thread.

Dasha_V - old’s picture

Use this:

extract($GLOBALS['filter']['variables']);

return '<pre>'.print_r(array(
  'args' => $args,
  'field' => $field,
  'row' => $row,
  'rows' => $rows,
  'output' => $output,
  'field_name' => $field_name,
  'row_index' => $row_index,
), TRUE).'</pre>';
pfharlock’s picture

The fix posted in #8 did the trick for me. Is there any chance we can get this change rolled into the mainline program?

Anonymous’s picture

#8 did not fix this for me, it just made views give me an error message when it tried to render it.

Seriously, I would think the owner of this module would care enough to get this resolved, considering so many people have this problem.

Anonymous’s picture

For those following this, what you're looking for in post #7 is the views_php_extension.zip file, install it like a regular module.

The test code in post#8 to print the available data in the arrays doesn't work with the views_php_extension module, but putting regular PHP in it does work, which is ultimately the point, so it does work :) Not perfect though ;)

I still wish the actual official module worked though.

betoaveiga’s picture

THANKS A LOOOOOT DASHA!!!! :)

vacilando’s picture

Same problem, subscribing.

freeform.steph’s picture

I also received an error when trying the suggestion in #8, and after much searching I found no way of making the variables available for use with this module.

As suggested in #7, what worked for me was the customfield module (http://drupal.org/project/views_customfield). This module provides 3 field options: PHP code, Markup, and rownumber. This module is not perfect though.

The Markup option allows you to use one of your site's defined input filters, which is great if you need access to a special filter for use with another module, however the Markup option, like Views Formatted Field, does not appear to provide access to the available variables.

In contrast, the PHP code option does allow you access to the variables, but does not allow you access to input filters. Combine these two options and you'd have a killer module, but for now, I am submitting to the limitations.

If you need to find out the variables that are available to you for this field, you can enter print_r($data); and run a preview of your view.

edrauta’s picture

Same problem, subiscribing, and don't work #8

Vote_Sizing_Steve’s picture

#8 worked for me - thanks.

off’s picture

Same issue

Vote_Sizing_Steve’s picture

Fix #8 worked for a long time, but I'm now getting a:

warning: extract() [function.extract]: First argument should be an array in ...

... error...

**Update** Never mind this post, I was generating the error because I was running #8 on a Customfield: PHP code field.