开发者

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

开发者 https://www.devze.com 2023-02-02 02:32 出处:网络
how to know th开发者_StackOverflowe 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 variab

how to know th开发者_StackOverflowe 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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号