0

This is at the top of the template file:

/**
 * @file
 * Default simple view template to all the fields as a row.
 *
 * - $view: The view in use.
 * - $fields: an array of $field objects. Each one contains:
 *   - $field->content: The output of the field.
 *   - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
 *   - $field->class: The safe class id to use.
 *   - $field->handler: The Views field handler object controlling this field. Do not use
 *     var_export to dump this object, as it can't handle the recursion.
 *   - $field->inline: Whether or not the field should be inline.
 *   - $field->inline_html: either div or span based on the above flag.
 *   - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
 *   - $field->wrapper_suffix: The closing tag for the wrapper.
 *   - $field->separator: an optional separator that may appear before a field.
 *   - $field->label: The wrap label text to use.
 *   - $field->label_html: The full HTML of the label to use including
 *     configured element type.
 * - $row: The raw result object from the query, with all data it fetched.
 *
 * @ingroup views_templates
 */

I was hoping "raw" was just the value in the field, but I think it's the entity id. PLEASE tell me there is a straight-forward way to get just the value of the field from this template!

Thanks!

3 Answers 3

1

Should be able to access the field's value with: $row->_field_data['nid']['entity']->field_YOUR_FIELD_NAME['und'][0]['value']

2
  • I don't like doing it this way, but it works, thank you. Sep 11, 2013 at 15:17
  • @SomethingOn I agree with you wholeheartedly, you'd think there'd be a simple way to access these. I did a lot of research when I had this problem myself and that was the only way I could find to access the value. Subscribing in case someone else has better answer. Sep 11, 2013 at 17:48
1

If you have devel installed then add dpm($field); to the template and see if the field array contains the value itself (if I remember right - it isn't). The second step (if the field array doesn't contain the value) will be to use dpm($view); ,and in the view array you have the value for sure (I think it is something like $view->$row['field_name'][0]['value'] )

0

You can use below code to render the fields into views template using below code.

$fields['title']->content

In above code title is name of the field. You can get the field name for the view's fields as below:

  • Go to Administration » Structure » Views
  • Edit your views
  • In the field section, click on last field in the views and check "Rewrite the output of this field" in the REWRITE RESULTS" section.
  • In the "REPLACEMENT PATTERNS" section, you will find the list of all fields which are placed before this field and this field also.

Selecting fieldname for the views fields

1
  • That still ends up giving me a <div> with the value...I just want the value. I find it incredibly silly that the value by itself isn't a variable option. Sep 11, 2013 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.