So i have made a view and a block for a carousel. I want to call this view or block in my template. (panels-pane.tpl.php).

I have tried to call the view with this function :

<?php $view = views_embed_view('carousel', 'carousel-block_1'); print $view; ?>

Unfortunately this is not working. Variable $view is NULL

I also tried to call a block in this template file with this function :

$block = module_invoke('views', 'block_view', 'carousel-block_1');
var_dump($block); // Empty ;s

Also not working..

The Delta ID is right. See Screenshot below for more information.

Do i something wrong?

enter image description here

Full page code with other view render (also not working):

// @codingStandardsIgnoreFile

 * @file panels-pane.tpl.php


<?php if ($pane_prefix): ?>
  <?php print $pane_prefix; ?>
<?php endif; ?>
  class="<?php print $classes; ?>" <?php print $id; ?> <?php print $attributes; ?>>
  <?php if ($admin_links): ?>
    <?php print $admin_links; ?>
  <?php endif; ?>

  <div class="pane-content">
    <?php $view = views_embed_view('downloads', 'downloads-product_downloads'); print $view;     var_dump($view); ?>
    <?php print render($title_prefix); ?>
    <?php if ($title): ?>
    <<?php print $title_heading; ?><?php print $title_attributes; ?>>
    <?php print $title; ?>
  </<?php print $title_heading; ?>>
<?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($feeds): ?>
    <div class="feed">
      <?php print $feeds; ?>
  <?php endif; ?>

  <?php print render($content); ?>

<?php if ($links): ?>
  <div class="links">
    <?php print $links; ?>
<?php endif; ?>

<?php if ($more): ?>
  <div class="more-link">
    <?php print $more; ?>
<?php endif; ?>
<?php if ($pane_suffix): ?>
  <?php print $pane_suffix; ?>
<?php endif; ?>

3 Answers 3


I hope views will never use hypens. May be you typed wrong.

Views always use underscores.

<?php $view = views_embed_view('carousel', 'carousel-block_1'); print $view; ?>

I think it should be

<?php $view = views_embed_view('carousel', 'carousel_block_1'); print $view; ?>

As per your template.php

<?php $view = views_embed_view('downloads', 'downloads_product_downloads'); print $view;     var_dump($view); ?>
  • Hi Nagarjuna! Sorry but this is not the solution :( Aug 16, 2016 at 16:21

This is how it works:

print views_embed_view('view_name','machine_name', $parameter);

In case you are wondering, this is the machine_name

$parameter is optional


$parameter = 1;
print views_embed_view('hello_world','block_1', $parameter);

So for your case, assuming your view is literally called/named Carousel, then it's probably:

<?php $view = views_embed_view('carousel', 'block_1'); print $view; ?>

Double check that your view is working. I have similar template code that works.

  • Hi Lars, Thanks for your answer but the view is working fine. Tried it also with other views but still no result. Aug 16, 2016 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.