Right now the first thing I do when using PHP code is this

echo str_replace('    ', '    ', nl2br(htmlentities(print_r($data, TRUE))));

Any chance you could place the output of this into a collapsed fieldset on the field edit form?

CommentFileSizeAuthor
#4 views_customfield-732158.patch3.76 KBmikeytown2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

How about having this code on the view form as a code box ready to paste in?

intyms’s picture

to put a collapsibe fieldset on the "Customfield" form, we have to add the following code to "views_customfield_handler_field_phpcode.inc" :

$form['variables'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Available variables'),
'#description' => 'i gues we have to put some code here',
);

place the code inside "function options_form(&$form, &$form_state)"
between $form['value'] and $form['sortable'].

The problem is that i don't know how to add the variables stored inside $data to the '#description' field from above.
Can anybody with php skils help to finish the implementation of this feature ?

Slovak’s picture

Subscribe

mikeytown2’s picture

Status: Active » Needs review
FileSize
3.76 KB

Here's a patch based off of #2. Makes the code ready to paste in.

intyms’s picture

I have observed just one thing, there are many "+" and "-" signs inside of the patch.

Everything else is great, patch forks very well !!! Thanks a lot!

intyms’s picture

Status: Needs review » Needs work
mikeytown2’s picture

Status: Needs work » Needs review

the + and - is my editor fixing white space issues automatically.
http://drupal.org/project/coder
http://drupal.org/coding-standards#indenting
If this is an issue I can manually roll out a new patch with the whitespace fixes removed.

intyms’s picture

oh, i see, sorry.

I tested the patch, it works great for me.

mikeytown2’s picture

Status: Needs review » Reviewed & tested by the community
iantresman’s picture

Is it possible to convert the output into "PHP Variable code"? For example, the patch outputs something like this:

[nid] => 12
[node_data_field_quantity_field_quantity_value] => 1
[node_type] => product
[node_data_field_quantity_field_price_value] => 20.00

But I'm not sure how to output either the value, or label, when using PHP. I have eventually worked out (and it took some time, and will take time when I try again in several weeks), that

To output the value of [node_data_field_quantity_field_price_value] I must enter:
<?php echo $data->node_data_field_quantity_field_price_value; ?>

which is not intuitive! And can you output anything else?