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?

Comments

askit’s picture

I have the same problem. It will be better if users can set default tab with Admin UI.

pasqualle’s picture

Version: 6.x-2.0-rc3 » 6.x-3.x-dev
Category: support » feature

yes, you are right, it would be nice..

stella’s picture

Status: Active » Needs review
StatusFileSize
new3.93 KB

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.

pasqualle’s picture

@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?

stella’s picture

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

katbailey’s picture

Version: 6.x-3.x-dev » 6.x-2.x-dev

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

jeffschuler’s picture

Status: Needs review » Reviewed & tested by the community

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.

alanburke’s picture

Looks like it could be done programatically with this patch.
You can define

$quicktabs['default_tab']

in your code [as far as I can see]
Alan

alanburke’s picture

StatusFileSize
new3.75 KB
+++ 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.

alanburke’s picture

Status: Reviewed & tested by the community » Needs review
katbailey’s picture

Status: Needs review » Fixed
StatusFileSize
new4.41 KB

Finally committed this with a few minor changes: http://drupal.org/cvs?commit=312044
FYI, here's the final patch that got in. Thanks Stella and Alan and sorry for taking so long!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.