I am having an issue with panels rendering both the primary and secondary tabs even if I specify to only render the secondary tabs in the panels settings when adding tabs.

Here is how I have been able to consistently reproduce the error on my panels sites.

  • Create fresh Drupal/Pressflow install
  • Install Ctools (with page manager enabled) and Panels
  • Go to the page manager page
  • Enable Node View
  • Edit Node View
  • Add a simple variant with almost all the defaults
  • Add Content -> Page Elements -> Tabs
  • Select "Secondary" under tab type
  • Create a new node (page, store, etc)
  • Now when you view the node after creating it, notice that the primary tabs (view, edit, etc) still show up.

Is there something I am missing? This seems like a very simple issue that is probably a setup mistake or a misunderstanding on my end. If I select "Secondary" as the tab type, it should no longer display those primary tabs. In fact it does not matter what I select for the tab type, it always renders the same. The above is a very simplified example of how to reproduce the error but I am in the process of building a site that wants to display the primary tabs horizontally and the secondary tabs vertically in a left sidebar on a panel page. As the above scenario describes it will show both the primary and secondary tabs no matter what tab type is selected.

It does not matter if this is on a panel page, node view, node edit, user view, or any other type of panel that I have tried, the results are always the same. And because in the example above I only installed 2 modules (ctools and panels) and only enabled (ctools, page manager, and panels), I am guessing it is either a misunderstanding on my end or an issue with panels.

Any suggestions or ideas are appreciated.

CommentFileSizeAuthor
#4 ctools_tab_display.patch2.03 KBcodekarate
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

codekarate’s picture

After further research it appears it may actually be a ctools issue based on how ctools renders tabs. I looked at page_tabs.inc (in ctools/plugins/content_types/page) and noticed this line of code:

$block->content = theme('menu_local_tasks');

This led me down a road of tracking down how ctools hijacks the 'menu_local_tasks' theme function in the "ctools_theme_menu_local_tasks" function in the file menu.inc (in ctools/includes).

I was able to put in some code to pass an extra parameter to the theme function based on the tab type the user selected but there are probably much better ways to go about doing this.

From the looks of it, it appears that selecting either "Primary", "Secondary", or "Primary & Secondary" from the panels settings for the tab type is not even being handled in the code.

I changed ctools_page_tabs_content_type_render function to:

function ctools_page_tabs_content_type_render($subtype, $conf, $panel_args) {
  $block = new stdClass();
  $block->content = theme('menu_local_tasks', $conf['type']);

  return $block;
}

And I changed the ctools_theme_menu_local_tasks function to:

function ctools_theme_menu_local_tasks($type = NULL) {
  $output = '';
  if (!isset($type) || $type == 'primary' || $type == 'both') {
    if ($primary = ctools_menu_primary_local_tasks()) {
      $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
    }
  }
  if (!isset($type) || $type == 'secondary' || $type == 'both') {
    if ($secondary = ctools_menu_secondary_local_tasks()) {
      $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
    }
  }
  return $output;
}

I am looking for a better and more correct way to do this as I have no idea how this will effect the other functionality of ctools, panels, or the core handling of menu tabs. I also have not extensively tested these changes, but they seemed to be working for at least my simple example from my first comment (assuming the theme is not garland since it's tabs are handled differently in the ctools code).

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

Ordinarily the tabs you refer to are rendered outside the panel. Are you referring to the tabs being referred outside the panel? Or are you saying that the secondary tabs content type is actually rendering the wrong tabs?

codekarate’s picture

Status: Postponed (maintainer needs more info) » Active

I would agree that normally the tabs are rendered outside the panel (by the theme), however we are using panels everywhere to take over the theme. We created a blank theme and we are using the default site template to render the primary tabs horizontally across the top and the secondary tabs in a left sidebar. My code changes work, but I threw it together very quickly and I am sure there is a more correct way to get this to work.

Thanks for the help.

codekarate’s picture

FileSize
2.03 KB

Here is a patch for ctools 6.x-1.8 that at least temporarily fixes the problem if anyone else needs to render the primary and secondary tabs separately in a panel. This has been briefly tested and is working but the maintainer or other panels/ctools experts may have a better solution.

Since this is a patch to ctools, should this be moved over to the ctools issue queue?

codekarate’s picture

Status: Active » Needs review
kasperg’s picture

Patch works for me. Thanks!

nicholasThompson’s picture

DamienMcKenna’s picture

vijaycs85’s picture

Status: Needs review » Closed (won't fix)

I would say the same as what we have in #1150638-5: Plugins: content types - page tabs not implemented.

This bug report has not been active for over six months. In an effort to clean-up the issue queue this item has been closed. If your modules are current and the report is still relevant please feel free to change the Status back to active.