runeveryday
runeveryday

Reputation: 2799

drupal-----views(how to know the fields name)

how to know the field variable name when output by views. eg:now, i want to overwrite a field's output, the name which i added is field_hello. but i don't know what's the variable name of it? namely how to print the variable in views-view-field--field_hello.tpl.php

Upvotes: 1

Views: 2270

Answers (3)

Flipmedia
Flipmedia

Reputation: 490

The simplest solution is to look inside the views module directory, views/theme/ all of these templates are the default view display and contain code that prints the varibles, arrays etc that your view will generate.

Upvotes: 0

Scott Reynen
Scott Reynen

Reputation: 3550

In the Views UI, under "Basic settings", you can click "Theme: Information" to get a list of what template files are currently being used and what file names can be used. You'll find all the default templates within your views/theme/ directory. If you copy one of those to create your custom template, e.g. views-view-field.tpl.php, you'll see they're heavily documented with all the variable names available. For field templates, you have $view, $field, $row, and $output. Depending on whether you want the pre-processed value or the processed value, you probably want $field or $output.

Upvotes: 1

DrColossos
DrColossos

Reputation: 12998

Using Theme Developer (formerly part of Devel), you can inspect a page and see what variables get passed to it and use them in your own templates.

If you talk about using a variable inside a views field: this is not possible due to security issues. Depending on the fields, there are some variables available and Vies tells you which one but you don't have easy access to ALL the variables that your template is able to process.

Upvotes: 0

Related Questions