/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Implementation of hook_views_pre_render(). * Check to reduce the number returned items to 2 from 3 if an advert is present in the view attachment. */ function modulename_views_pre_render(&$view) { //bit nasty? global $alter_num_results; if (($view->name == 'News' && $view->current_display == 'block_1') || ($view->name == 'News' && $view->current_display == 'attachment_1')) { //If the attachment has a result nid then it has an advert to display so mark alter_num_results as true if($view->current_display == 'attachment_1' && $view->result[0]->nid){ $alter_num_results = 'TRUE'; } //If the marker is true then unset the 3rd item if($view->current_display == 'block_1' && $alter_num_results == 'TRUE'){ } } }