Code - Community - Collaboration
Drupal.se

Embedding multiple views blocks in a loop

This was something that never seems to be done in any tutorial about views_embed_view. I needed to embed views block displays and their titles as they were being added to the view.

<?php
// $views_get and views_embed because one gets the display title
// the other gets the view by display
// why is there no single function way of doing this is not known by me
foreach($viewdisplaylist as $display_name):
 
$view = views_get_view('view_name', $display_name);
 
?>
 
 
<h3><?php echo ($view->display[$display_name]->display_title); ?></h3>	
  	<?php echo views_embed_view('view_name', $display_name); ?>
 
<?php endforeach; ?>


Tags: 
Free tagging: