douliang1891 2010-06-03 12:04
浏览 33
已采纳

Drupal Views拉动数据字段

I'm a little new to drupal but have been using things like devel module and theme developer to speed up the learning process.

My question, is it possible to theme an entire views BLOCK from a single views tpl.php page OR even a preprocess?

When I'm grabbing the $view object I can see results $node->result, it has all of the results, but it doesn't have all my views fields. I'm missing things like, node path, taxonomy titles and paths, etc.

From my understanding, Drupal wants you to individually theme EACH output field. It seems rather superfluous to create so many extra templates when I've already got over HALF of my results coming through the $view object

Would outputting node over field make this easier? Or am going in the wrong direction with $view->result?

Thanks!

  • 写回答

1条回答 默认 最新

  • doumalu9257 2010-06-03 17:21
    关注

    this page might help: http://drupal.org/node/342132

    I rarely theme at the views field level -- agreed: it's too many files to edit. So I either do it at the node/teaser level, or load the view programmatically, and then display it in a function in my glue module.

    whether to do nodes or fields depends on how else you're displaying the items. for example, if the only way you're using teasers is in this view, it might simplify things to do the theming in the node-mytype.tpl.php file. If you have four different views, all of which have different themes, you might use the glue module approach. There's also the css-only appraoch. Or, sometimes, views theming truly is the best option.

    update: you can also use node_load in your glue module to get more node info. That can be expensive, performance-wise, depending on the size of your view and how often the nodes change. (node_load does some caching...)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号