I’m developing an application that which will work as a standalone website and will also get rendered inside of a Facebook frame, i.e. a Facebook app.
Only a small section of the website will be available in the Facebook frame so I need a way of switching layouts depending on whether it’s rendered in the frame.
I think the easiest way would be to use a distinct url for accessing the site through Facebook. For example if the external website is at http://www.xyz.com, configure fb.xyz.com on your webserver (and dns) to point to the same place and then use fb.xyz.com in your app settings. Your scripts can then easily check the hostname and determine if it’s an app request or not.
A similar way would be to make a subdirectory that is just a symbolic link to the main directory and call it something like “faceapp”. In other words have http://www.xyz.com and http://www.xyz.com/faceapp pointing the same place. Then of course use http://www.xyz.com/faceapp/ in your app settings. In your PHP you can do something like this:
and use the $faceapp variable to determine how to render parts of the page.