Drupal 7 tabs activation using url
Drupal 7 has the field开发者_StackOverflow中文版 group module which contains a horizontal_tab.js
file.
Inside this file i found this written
// If the current URL has a fragment and one of the tabs contains an
// element that matches the URL fragment, activate that tab.
if (window.location.hash && $(window.location.hash, this).length) {
tab_focus = $(window.location.hash, this).closest('.horizontal-tabs-pane');
}
Can someone explain how this would work and what exact url i should call so that a particular tab is activated.
If your current url is something like http://www.example.com/test.htm#part2:
location.hash will give you the hash value
i.e #part2
From their comment.
// If the current URL has a fragment and one of the tabs contains an
// element that matches the URL fragment, activate that tab.
Means if the hash value matches, they are trying to find the closest element with class
'.horizontal-tabs-pane'
If so they are focusing the tab.
Our field_group module have one file with name modules/field_group/horizontal-tabs/horizontal-tabs.js
and in this file at line number 38 add this line alert(this.id)
Its print Id of perticular tab. After finding this id you can pass in your url with #(hash)
ex : alert(this.id);
After page URL add this ID with # sign so its by default open specified Tab
Combination of Id goes like this
Syntax => node_YourContentTypeName_full_group_YourFieldName
Example => node_product_full_group_item_name
here product is content type and item_name is field name
精彩评论