Default Tab
jeffschuler - May 12, 2009 - 03:37
| Project: | Quick Tabs |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Is it possible to set a particular tab as default without using a URL argument (as described in #308633 ) ?
I'm using QuickTabs for a semi-dynamic week calendar here: http://www.clevelandbicycleweek.org (scroll down half-way.)
It's nearly Tuesday, and I figured there was an easy way to set each current day's tab as default -- (even if I have to set it manually.)
I could do an HTTP redirect to ?quicktabs_1=2 ... but redirects are relatively expensive.
Maybe there's a feature I'm missing or a more appropriate solution than QuickTabs?

#1
I have the same problem. It will be better if users can set default tab with Admin UI.
#2
yes, you are right, it would be nice..
#3
Here's a patch that provides this functionality, though it's not present when adding a new quicktab because there's none to choose from.
#4
@stella quick question: is it a problem for you if this feature would be part of 6.x-3.x, but not part of 6.x-2.x? as I do not know when 6.x-3.x version will have stable releases. Are you comfortable using 6.x-3.x-alpha on sites where you need this feature?
#5
well i'm running a version of 6.x-2.x quicktabs with this patch applied, and i'm happy to keep re-rolling it as needed, so feel free to postpone to 3.x
#6
Hi All,
I'm happy to commit this patch to the 2.x version - have tested it on some existing sites and it causes no problems at all - all a user has to do is run update.php and they have this functionality. Any further comments before I commit to 2.x?
Thanks Stella!
K
#7
Awesome: thanks Stella and katbailey!
Patch worked great on 6.x-2.x-dev.
What would make it really useful for me would be to allow that choice to be done programmatically: if I could provide a bit of php to choose the tab.
For example, in the case of the site I originally mentioned, where each tab is a day of the week, I'd find the current date then set the default tab based on it...
RTBC, tho, IMHO.
#8
Looks like it could be done programatically with this patch.
You can define
<?php$quicktabs['default_tab']
?>
in your code [as far as I can see]
Alan
#9
+++ quicktabs.module 11 Sep 2009 21:04:14 -0000@@ -189,6 +189,7 @@ function quicktabs_render($quicktabs) {
$output = '<div'. $attributes .'>';
$active_tab = _quicktabs_get_active_tab($quicktabs);
+ $active_tab = ($active_tab ? $active_tab : $quicktabs['default_tab']);
$output .= theme('quicktabs_tabs', $quicktabs, $active_tab);
Hmm, I'm not sure this will do the trick [for me :-) ].
The function _quicktabs_get_active_tab($quicktabs)
doesn't ever return NULL, it will always return the key of the quicktabs array, if it exists.
/**519 * Helper function to determine active tab from the url.
520 */
521 function _quicktabs_get_active_tab($quicktabs) {
522 $active_tab = isset($_GET['quicktabs_'. $quicktabs['qtid']]) ? $_GET['quicktabs_'. $quicktabs['qtid']] : key($quicktabs['tabs']);
523 if (isset($active_tab) && isset($quicktabs['tabs'][$active_tab])) {
524 return $active_tab;
525 }
526 return NULL;
527 }
So I moved the test for the default tab down to that function.
Seems to do the job for me.
I can now define
$quicktabs['default_tab']in my manually created $quicktabs array.
Alan
This review is powered by Dreditor.
#10