简体   繁体   中英

Drupal- How to get views field values using PHP Code?

I have created a node in drupal with cck fields on it and I created a views to display the contents. Now what I wanted is on a specific area of my page I wanted to get the views result and display it the way I wanted it to be. I know that this can be achieve using region/blocks but what I wanted is to change the layout or display the values in different order/element.

Your reply is greatly appreciated.

Thanks,

You will probably want to just override your views theme output and change there the layout of your views results. You can override about any output, fields layout, nodes layout, page layout. For a quick look at what kind of theme templates you must copy/edit into your theme, check the "Theme information" section on you views display. It's on the base settings of your views.

The theme information is a link in the View module admin. You should see the text Theme Information as a link when creating your views. You will see the first template file for each piece of the view (row, style, then it will list each of your fields). You can override these templates by copying the name of the template files that aren't in bold (those following in the list) and creating a file with that name in your template's directory. I typically make a folder called "views" in the templates folder but I don't believe that is required. You can access your fields with different names depending on where they came from. Use get_defined_vars() to get the names of your variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM