O'Reilly logo

Facebook Cookbook by Jay Goldman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying a User’s Name

Problem

How do I display a user’s name?

Solution

Use the <fb:name> tag. Among the many options you can include, specify the uid of the user whose name you want to display (you can also use loggedinuser or profileowner).

Discussion

This tag is interesting because of the various ways that different languages deal with possessive nouns and other grammatical structures, which I can never keep straight. (Is the participle dangling? What does that even mean?) This is a great example of FBML saving you from having to add giant if/else blocks to your code. The parameters are listed in Table 6-1.

Table 6-1. Parameters for fb:name

Name

Type

Default value

Description

They see

I see

uid

uid

N/A

The Facebook user ID (uid) of the user or Page whose name you want to show. You can also use loggedinuser or profileowner. This is the only required field.

“Jay Goldman”

“You”

capitalize

bool

false

Capitalize the text if useyou is true and loggedinuser is the uid.

“Jay Goldman”

“You”

firstnameonly

bool

false

Show only the user’s first name.

“Jay”

“You”

ifcantsee

string

Empty

Alternate text to display if the logged-in user cannot access the user specified.

Specified text if they can’t see me; “Jay Goldman” if they can

“You”

lastnameonly

bool

false

Show only the user’s last name.

“Goldman”

“You”

linked

bool

true

Link to the user’s Profile.

“Jay Goldman”

“You”

possessive

bool

false

Use the possessive form (his/her/your).

“Jay Goldman’s”

“Your”

reflexive

bool

false

Use the reflexive form (himself/herself/yourself). ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required