钩子视图预渲染Drupal 6.x

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了钩子视图预渲染Drupal 6.x相关的知识,希望对你有一定的参考价值。

  1. /**
  2.  * Implementation of hook_views_pre_render().
  3.  * Check to reduce the number returned items to 2 from 3 if an advert is present in the view attachment.
  4. */
  5. function modulename_views_pre_render(&$view) {
  6. //bit nasty?
  7. global $alter_num_results;
  8. if (($view->name == 'News' && $view->current_display == 'block_1') || ($view->name == 'News' && $view->current_display == 'attachment_1')) {
  9. //If the attachment has a result nid then it has an advert to display so mark alter_num_results as true
  10. if($view->current_display == 'attachment_1' && $view->result[0]->nid){
  11. $alter_num_results = 'TRUE';
  12. }
  13. //If the marker is true then unset the 3rd item
  14. if($view->current_display == 'block_1' && $alter_num_results == 'TRUE'){
  15. unset($view->result[2]);
  16. }
  17. }
  18. }

以上是关于钩子视图预渲染Drupal 6.x的主要内容,如果未能解决你的问题,请参考以下文章

在视图 2 (Drupal 6) 中检索被覆盖的主题钩子的名称

在 Drupal 视图中更改视图的字段文本

如何更改drupal 7中视图的[编辑节点链接]

确保Drupal模块中的钩子在其他钩子之前运行。

drupal 7在ubercart 3.x中成功付款的钩子是啥

drupal 7 使用模块视图自定义行样式