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 | N/A | The Facebook user ID
( | “Jay Goldman” | “You” |
| bool | | Capitalize the text if
| “Jay Goldman” | “You” |
| bool | | Show only the user’s first name. | “Jay” | “You” |
| 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” |
| bool | | Show only the user’s last name. | “Goldman” | “You” |
| bool | | Link to the user’s Profile. | “Jay Goldman” | “You” |
| bool | | Use the possessive form (his/her/your). | “Jay Goldman’s” | “Your” |
| bool | | Use the reflexive form (himself/herself/yourself). ... |
Get Facebook Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.