0

I get this error Strict warning:

Only variables should be passed by reference in include() (line 20 of ...)

Can anybody see what is wrong here?

<section id="fixed-navbar">
  <nav class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container">
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav">
          <span class="sr-only"><?php print t('Toggle navigation'); ?></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" rel="home" href="<?php print url('<front>'); ?>" title="<?php print variable_get('site_name', ''); ?>">
          <?php print isset($logo) && $logo ? theme('image', array('path' => $logo)) : '<h3>' . variable_get('site_name', '') . '</h3>'; ?>
        </a>
      </div>

      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="main-nav">
        <ul class="nav navbar-nav  navbar-right">
          <?php print drupal_render(menu_tree_output(menu_tree_all_data('menu-top-menu'))); ?>
        </ul>
      </div><!-- /.navbar-collapse -->
    </div><!-- /.container -->
  </nav>

</section>
1

The error is because you're trying to directly pass menu_tree_output() function return value to drupal_render() function. Which is not allowed because drupal_render() accepts $element as call by reference. When accepting arguments as call by reference those must be passed as variable (preferred).

So your code should look like below:

<nav>
  <div class="container">
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="main-nav">
      <ul class="nav navbar-nav navbar-right">
        <?php $menu_output = menu_tree_output(menu_tree_all_data('menu-top-menu')); ?>
        <?php print drupal_render($menu_output); ?>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container -->
</nav>

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