Online Book Reader

Home Category

Facebook Cookbook - Jay Goldman [60]

By Root 682 0
(tags that provide actual user interface widgets, such as fb:comments)

Control (tags that control what gets displayed on your page, such as fb:visible-to-owner)

The other way to slice and dice is based on the area of functionality they affect (see all of the tags grouped this way on http://wiki.developers.facebook.com/index.php/FBML):

Dialog (display a Facebook-style dialog, either pop-up or contextual)

Editor display (display a Facebook-style form with labels)

Embedded media (embed media such as Flash, Silverlight, MP3s, etc.)

Forms (enable images or text links to act as form submission controls)

Message/Wall attachments (preview attachments to messages or Wall posts)

Misc (things that don’t fit somewhere else)

Notifications and requests (content for the Notification and Request integration points)

Page navigation (navigation widgets, including dashboards and tabs)

Profile-specific (FBML that works only in Profile Boxes)

Status messages (display Facebook-style errors and messages)

Tools (assorted tools, including various friend selectors and Google Analytics)

User/Groups (display information related to users)

Visibility on Profile (control who can see what on Profiles)

Wall (emulate a Wall-like environment in your app)

Discussion


One of the biggest differences between HTML and FBML is the context of the logged-in users. Tags in HTML always render the same content, regardless of who looks at them, so there’s never a need to think about what someone will see depending on which state she’s in. FBML is different, and the first grouping provides a handy way to remember which tags are affected by context and which ones aren’t.

Social tags are very aware of who’s logged in and what they can see. For example, the fb:name tag will render the specified user’s full name to someone who is logged into Facebook, but only that user’s first name to someone who isn’t. The output of sanitization tags generally doesn’t change from user to user, but the content they add to a page might (e.g., standard HTML

s will get some hidden fields automatically added, including the UID of the current user). Design and Component tags are almost all user-agnostic, as they tend to be shortcuts to blocks of HTML or advanced functionality rather than user-specific content that needs to be aware of privacy concerns. Control tags are highly user-aware, since their primary purpose is to control display of content based on who’s looking at it.

FBML Versions


Problem


I know there are different versions of FBML and some tags require FBML 1.1, but how do I set or even know which version I’m using?

Solution


Wrap your FBML in fb:fbml tags and specify a version you want them executed with:

Discussion


You can include an fb:fbmlversion tag inside an fb:fbml tag to output which version is being used to parse that content, though you should note that this is really only intended for debugging purposes. As an example, the following:

This is

This is

This is

will give you:

This is 1.0

This is 1.1

You might have expected to get a third paragraph for 1.2, but the FBML parser ignores it because that version didn’t exist at the time this book was written. Using an fb:fbmlversion tag outside of an explicit fb:fbml tag should give you 1.0, since that’s the assumed default if you haven’t specified otherwise.

A Rose by Any Other Name: Forced Renaming


Problem


Facebook keeps renaming all of the ids in my HTML.

Solution


It’s cool! Relax, man. You’re in the Sandbox! The Sandbox is groovy.

No, seriously. The Sandbox is just doing its job, protecting the forces of good (namely, you) from the evil demon know as namespace clash. Sandboxes in the computer science sense are a security mechanism for safely running programs in a contained

Return Main Page Previous Page Next Page

®Online Book Reader