Fbtt Facebooker Tutorial

Next Lesson → Invite Friends

2.1) Tabs


This lesson shows you how to render a facebook tab control.

FBML tab control is handled by two methods, fb_tabs and fb_tab_item. If you check out the wiki you will see that fb_tabs tag contains some number of fb_tab_item tags. Here is how the tab control is created for this tutorial.

  1. Create a method to determine if the current tab is selected or not.
    1
    2
    3
    4
    
    #File: app/helpers/application_helper.rb Method: tab_selected?
    def tab_selected?(section)
       (section.lessons.first.url_options[:controller] == params[:controller])
    end
    
  2. Now create the fb_tabs container and all the fb_tab_items
    1
    2
    3
    4
    5
    
    # File: app/views/layouts/_section_tabs.rhtml
            
        <% fb_tabs do %>  
               <%= section_tab_items() %>  
        <% end %>      
    1
    2
    3
    4
    5
    6
    
    #File: app/helpers/application_helper.rb Method: section_tab_items
    def section_tab_items
       LessonOutline.outline.sections.collect do |section|
          fb_tab_item(section.name, url_for(section.lessons.first.url_options), :selected => tab_selected?(section) )
       end.join("\n")
    end
    
    Note: fb_tabs method is a little touchy on what the block that you pass it does. The is why I factored out the code that returns the tab_items.
Next Lesson → Invite Friends
Peepcodead
Comment Section for Tabs

Säkerhetskontroll

Skriv in båda orden nedanför, avgränsade med ett mellanrum.
Kan du inte läsa orden här nedanför? Pröva olika ord eller en ljud-captcha.
Laddar ...

Ace Suaresden 6 oktober 2009

ahhh... those tabs don't work in an iframe with XFBML... http://forum.developers.facebook.com/viewtopic.php?pid=121903#p121903
 

Steve Hullden 23 mars 2009

Ummm the tabs/menu system are not displayed when you just go to http://apps.facebook.com/facebooker_tutorial -- this seems like a major oversight, as that link is the only "Facebooker tutorial" I found for days...
 

Evan Andersonden 10 september 2008

I approached this slightly differently using the url_for as the core of my tab_selected? method and compared it to the current url, perhaps not the cleanest but just another option.
 

David Clementsden 6 mars 2008

Forms is on my list of things to do. There are some decent examples in the facebooker docs I think.
 

Zia Syedden 5 mars 2008

Any idea when can we have a look at the source code. Right now, I'm stuck at handling fbml forms request.
 

Jorge Miramontesden 28 februari 2008

Yeah, a download of the source would be the most helpful I think. That way people could ask deeper questions that just ask about simple logistics. Thanks.
 

David Clementsden 27 februari 2008

LessonOutline is a class that is used just in this tutorial. You can put anything you want in there. I think I need to make those things more clear. Or provide the Tutorial Source to download.
 

Jorge Miramontesden 27 februari 2008

What subclass does 'LessonOutline' inherit from? Where should I put it?
 

David Fugereden 18 februari 2008

ok
 
Visar alla 9 inlägg