Friday, June 4, 2010

How to add tabs to joomla component

mosTabs is no longer available in Joomla 1.5. Use this method instead to add tabbed content to your component or module in Joomla 1.5 native mode.








  • Include this line of code before you start your tabs

     1 

    jimport ( 'joomla.html.pane');






  • Then get the instance for the tabs and assign it to a variable:

     1 

    $myTabs = & JPane::getInstance ( 'tabs' );





  • Use the code below to define your tabs:

      1 
      2 
      3 
      4 
      5 
      6 
      7 
      8 
      9 
     10 
     11 
     12 
     13 
     14 
     15 
     16 
     17 
     18 
     19 
     20 
     21 
     22 


      // Start the tabs
      echo $myTabs->startPane( "my_tabs" );

      // Start the first Tab definition
      echo $myTabs->startPanel(JText::_('First Tab'),'tab1_id');

      // Add the content for the First Tab here...
      
      // Close the First Tab
      echo $myTabs->endPanel();
      
     
      // Start the Tab2 definition
      echo $myTabs->startPanel(JText::_('Second Tab'),'tab2_id');

      // Add the content for the Second Tab here...

      // Close the Second Tab
      echo $myTabs->endPanel();

      // Close the tabs
      echo $myTabs->endPane();






  • An alternative to tabs is the slider. To display your content in sliders just get the instance for 'sliders' instead of 'tabs' as shown in the following line of code:

     1 

    $myTabs =& JPane::getInstance( 'sliders' );


No comments:

Post a Comment