Tip: Choosing the active tab on a redirect

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Tip: Choosing the active tab on a redirect

Post by calguy1000 »

Sometimes when you hit the submit button on a tab's form you want to go back to the same tab, or to a different one other than the default.
(applies to the 0.11.2 series or later)

Here's how.
  In your tab setup

Code: Select all

$active_tab = ''';
if( isset( $params['active_tab'] )
   $active_tab = $params['active_tab'];
then

Code: Select all

echo $this->StartTabHeaders();
echo $this->StartTab('tab1','My Tab 1', ($active_tab == 'tab1'))
echo $this->StartTab('tab2','My Tab 2',($active_tab == 'tab2'));
...
Then in your code for handling forms.... when done

Code: Select all

unset( $params['action'] );    // this shouldn't be necessary if using active svn 
$params['active_tab'] = 'tab1';
$this->Redirect($id, 'defaultadmin', '', $params );
Note the empty quotes in the third parameter to Redirect....
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
prefab

Re: Tip: Choosing the active tab on a redirect

Post by prefab »

calguy1000 wrote:
then

Code: Select all

echo $this->StartTabHeaders();
echo $this->StartTab('tab1','My Tab 1', ($active_tab == 'tab1'))
echo $this->StartTab('tab2','My Tab 2',($active_tab == 'tab2'));
...
Hello,

Thank you for this tip, I was just looking for a way to do this. I am using 0.13. I looked in the API and it seems that active tab is a parameter for SetTabHeader, rather than StartTab. So the code should be:

Code: Select all

echo $this->StartTabHeaders();
echo $this->SetTabHeader('tab1',$this->Lang('tab1'), ($active_tab == 'tab1'));
echo $this->SetTabHeader('tab2',$this->Lang('tab2'),($active_tab == 'tab2'));
...
There is also more information here
http://wiki.cmsmadesimple.org/index.php ... ertain_tab

cheers
Last edited by prefab on Mon Jun 12, 2006 7:36 pm, edited 1 time in total.
Post Reply

Return to “Modules/Add-Ons”