hook_views_pre_render Drupal 6.x


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.