It would be great if direct links to a fieldgroup are possible.

at the moment a link to www.example.com/node/11/edit#some_tab brings you to the edit form but the javascript is not processed and all fieldgroups are shown as fieldgroups.

desired is the edit form with the tab opened.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jenlampton’s picture

Title: Enable direct link to a tab » tab not active when fragment passed in url
Version: 6.x-1.0-beta1 » 6.x-1.0-beta3
Category: feature » bug

I'm pretty sure this is a bug and not a feature request.
I could be wrong, but it seems fairly important.
Jen

mErilainen’s picture

+1 for this
It comes in handy when inserting links to profile fields saying "You haven't added you birthday yet. Add it here"

ptoly’s picture

+ 1
bump

Dave Reid’s picture

Title: tab not active when fragment passed in url » Activate current tab from URL fragment
Version: 6.x-1.0-beta3 » 6.x-1.x-dev
Category: bug » feature

Minor annoyance, but this is a feature request. Patches welcome. :)

Dave Reid’s picture

Title: Activate current tab from URL fragment » Activate current vertical tab from URL fragment
Project: Vertical Tabs » Drupal core
Version: 6.x-1.x-dev » 7.x-dev
Component: Code » javascript
Issue tags: +vertical tabs
FileSize
1.39 KB

Here's the patch for the D6 module, but I'd like to see this fixed in D7 as well.

casey’s picture

Status: Active » Needs review
FileSize
875 bytes

Patch for D7

moshe weitzman’s picture

This looks good. One caveat is that there is already some code to keep you on the same tab when you submit a form. and that should continue to work. so, if i get sent to a tabbed page with #some_tab and then i open up #other_tab and submit the form, i want #other_tab to stay open.

casey’s picture

Won't you lose the URL fragment when you submit a form (with node edit form you do)? In that case it'll re-activate the tab you had active before.

I moved this check before the hidden input (.vertical-tabs-active-tab) as it seems that that input is always present in node edit forms.

seancorrales’s picture

FileSize
1.31 KB

Tried #5 and it worked but one small problem - the right pane was selected but none of the content was shown.

Re-rolled a patch and fixed the issue by changing around the order some - I put the hide statement for all the panes first and then put the code in for the fragment piece. Only tested on the node edit form using Vertical Tabs 6.x-1.0-rc1.

Saeh’s picture

in this included in drupal 6? or do i still need to patch the latest release to get it to work

restyler’s picture

Is there a way to remember the last opened vtab, based on hash, after form submit, in 6.x?

aspilicious’s picture

Lets fix this first in D7...

moshe weitzman’s picture

FileSize
875 bytes

Re-upload last d7 patch - #6

Status: Needs review » Needs work

The last submitted patch, verticaltabsactive.patch, failed testing.

casey’s picture

Status: Needs work » Needs review
FileSize
974 bytes
moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

this will do nicely. thanks.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Dave Reid’s picture

Project: Drupal core » Vertical Tabs
Version: 7.x-dev » 6.x-1.x-dev
Component: javascript » Code
Status: Fixed » Patch (to be ported)

Moving to backport to D6, and then I will move this back to the Drupal queue once backported.

g.k’s picture

I applied #9 fragment-D6.patch for my D6 installation and it works fine if the URL (with anchor) was called from a different page, but it doesn't switch tabs if the tab is on the same page. Also, it would be nice UI experience if the page scroll down automatically and highlight the active tab.

dmitrig01’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

If that worked as you described then it doesn't need a port.

dmitrig01’s picture

If that worked as you described then it doesn't need a port.

jasonlttl’s picture

It would be nice if the d6 patch in #9 could be committed. I just tested it on one of our d6 sites, and it seemed to work fine with the caveat (#19) that, on the node edit form, hand crafted links don't work unless you do something special.

I think the code in #9 only handles initial page load and that the vertical tabs way is to have the initiating link trigger the action. For example, in vt code, it does something like this.

      $('<li class="vertical-tab-button"><a href="#' + k + '" class="' + cssClass + '"><strong>'+ v.name + '</strong>' + summary +'</a></li>').appendTo(ul)
        .find('a')
        .bind('click', function() {
          $(this).parent().addClass('selected').siblings().removeClass('selected');
          $('.vertical-tabs-' + k).show().siblings('.vertical-tabs-pane').hide();
          return false;
      });

If you want to make custom links drive vertical tabs from the same page, putting something like this in the onclick handler works (although you wouldn't want it on an external page). I'm guessing this is probably not something one would want vertical tabs to do automatically.

$('.vertical-tabs-list-".$fieldset."').parent().addClass('selected').siblings().removeClass('selected');
$('.vertical-tabs-".$fieldset."').show().siblings('.vertical-tabs-pane').hide();
robcarr’s picture

I think patch at #9 is fine for Drupal 6. Just tried it and works fine. Could someone commit??

lefnire’s picture

#9 needs a re-roll for rc2

update: woops, never mind me -- works against the -dev

JamesK’s picture

subscribe

grasmash’s picture

yes, it would be great to get this committed. very useful.

firestonej’s picture

I see that this has been implemented, but it doesn't work with vertical or horizontal tabs.

I must be missing something, because it seems like this line:

if (window.location.hash && $(window.location.hash, this).length) {

Will never select anything with the second statement. The fieldgroups aren't generated with any IDs. If I manually edit that selector to target something else, or alter the markup myself, I can get this to work. However, it's definitely not functioning by itself.

D7.9, FieldGroups 1.1 .. running on IIS, if it matters.

firestonej’s picture

Okay, cancel that. I finally figured out what it's attempting to target.

I was under the impression it was looking for a reasonably formed ID / the name of the tab. Now I see it's looking for a mangled, non-restful underscore nightmare. I'm probably on my own from here, but it seems like those tab IDs should be the names that you assign in the content type admin..

El Bandito’s picture

Hi

From #19 :

Also, it would be nice UI experience if the page scroll down automatically and highlight the active tab.

Me too.

El B

grasmash’s picture

@29

Here's a snippet that I used for that:

  /* if this is an edit page and fragment was specified, scroll to vertical tabs */  
  var url = location.pathname;
    if (url.indexOf('/edit') && window.location.hash.length > 0) {
      /* this waits until all of the other jQuery has loaded, e.g., vertical tabs */      
      $(window).load(function(){ $('html, body', context).animate({ scrollTop: $('.vertical-tabs').offset().top });
      $('.vertical-tab-button a[href="' + window.location.hash + '"]', context).click();
    });
  }
cluther’s picture

I've been unable to implement this feature in D7 or find a working example of code. What I've tried:

  1. I've created a content type with several fieldsets configured as vertical tabs (ed: group_set1, group_set2, group_set3).
  2. On a separate page I've created a link to the the node edit form using the pattern http://www.example.com/node/11/edit#group_set2.
  3. The link opens the form but does not select the designated vertical tab. The default tab 1 is active.
  4. I looked in the code expecting for find unique CSS IDs for each of the vertical tabs, but could only find the following css classes: vertical-tab-button, first, last, selected.

DUH moment - It wasn't until I posted this comment that I noticed that this issue thread was for a Drupal 6 module and not for the vertical tabs that is part of core Drupal 7. I could not find an issue in Drupal 7 Core for this feature, so I've created a feature request here: http://drupal.org/node/1615474

At this point, other that attempting to submit a patch to D7 Core, I don't know what else I can do. Still ideas and suggestions are welcome. Thanks in advance.

Chris

Elijah Lynn’s picture

Elijah Lynn’s picture

RE #31 - #15 was committed with http://cgit.drupalcode.org/drupal/commit/?id=093f99a794e0ff6107fbd052560... and you can use the name of the vertical tab as the hash, in my experience though, it is case sensitive, maybe this shouldn't be case sensitive.

Here is an example if you have a tab named 'Vertical Tab Name':
#Vertical Tab Name
#Vertical+Tab+Name

#Vertical tab name (will not work)

Elijah Lynn’s picture

@cluther - I know this is 4 years later but I submitted a follow up issue to update the URL bar with the hash when a vertical tab is selected. This will show how to link them. We should open a new issue to make them case insensitive, since URLs in Drupal 7 are also case-insensitive.

#2752511: Update location.hash when clicking a vertical tab