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); ?>
<?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 ?


Finally I ended up like this:

  $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.


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


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();


<?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; ?>
<?php endif; ?> 
  • Your solution is also correct, but i have implemented as below. – mohit_rocks Dec 3 '12 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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