1

I am creating subtheme of bartik theme.

According to page.tpl.php file of Bartik theme it shows that tabs can be printed by following code.

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

The above code prints primary and secondary tabs at a single place.

Now i want to print primary and secondary tabs seperately in template file.

Is there any variable which gives me the primary and secondary tabs seperately ?

2 Answers 2

4

Finally I ended up like this:

<?php 
  $primary = menu_primary_local_tasks();
?>
<ul class="tabs primary primary-with-secondary clear-block"><?php print render($primary); ?></ul>

The above code will return the primary links:

To print the secondary links

 if ($secondary = menu_secondary_local_tasks()) {
    $output .= "<ul class=\"tabs secondary clear-block\">\n". $secondary ."</ul>\n";
  }

Above code will return the secondary links for the theme.

0
1

You might wanna set some variables for your page template...

/themes/YOURTHEME/template.php

function YOURTHEME_process_page(&$vars) {
  // Set local tasks variables
  $vars['primary_local_tasks'] = menu_primary_local_tasks();
  $vars['secondary_local_tasks'] = menu_secondary_local_tasks();
}

/themes/YOURTHEME/templates/page.tpl.php

<?php if ($primary_local_tasks || $secondary_local_tasks): ?>
<div id="tasks">
<?php if ($primary_local_tasks): ?>
<ul class="tabs primary"><?php print render($primary_local_tasks); ?></ul>
<?php endif; ?>
<?php if ($secondary_local_tasks): ?>
<ul class="tabs secondary"><?php print render($secondary_local_tasks); ?></ul>
<?php endif; ?>
</div>
<?php endif; ?> 
1
  • Your solution is also correct, but i have implemented as below. Commented Dec 3, 2012 at 11:54

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.