Talk:Fb:tabs

From Facebook Developer Wiki

Jump to: navigation, search

It'd be great to be able to drop the line spanning the page beneath the tabs by invoking some appropriate tag.



Is there a way to specify the size of the font in tabs? For some reason, mine is bigger than usual.




Ok, here is a bit of PHP code I wrote to make life easier with tabs:

Declare the tabs in an array.

First element is the filename to where the tab should link, second element is the label of the tab. I put that in my constants.php file

  $tabs    = array(
     'index.php' => 'Home',
     'help.php' => 'Help',
     'about.php' => 'About Us'               
  );


Define a function

It will display the tabs, setting the appropriate tab as 'selected'. I put that in my functions.php file.


  function getTabs($tabname) {
     echo '<fb:tabs>';
     $temparray = $GLOBALS['tabs'];
     while ($tab = current($temparray)){
        $curtab = key($temparray);
        $selected = ($curtab==$tabname ? 'true' : 'false');
        echo '   <fb:tab-item href="'.$GLOBALS['fb_url'].'/'.$curtab.'" title="'.$tab.'" selected="'.$selected.'"/>';   
        next($temparray);
     }
     echo '</fb:tabs>';
  }


NOTE: fb_url is the path to my facebook canvas, for example: http://apps.new.facebook.com/example/

NOTE2: for some reason, when linking to a page of your app you have to add an extra / (eg: http://apps.new.facebook.com/example//help.php hence the extra '/' after $GLOBALS['fb_url']

Use the function

In your tab files (eg: index.php), call the getTabs function with your file's name as input.

  getTabs('index.php');

[edit] RequireLogin

It is a shame that requirelogin doesn't work with tabs.


[edit] Customization

Would have been great if the tabs could support images and styles as well.

reference