Facebook not using fbml theme
seanr - October 30, 2007 - 16:11
| Project: | Drupal for Facebook |
| Version: | 6.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Description
The documention does not say that you have to set the default theme to fb_fbml, but for some reason, that seems to be the only way I can get Facebook to properly use it. Otherwise, it tries to use Garland, which throws tons of facebook code errors. How do I get Facebook to use the correct theme, while people visiting my site directly get the normal one?

#1
You do not need to set fb_fbml to the default. You do not even need to enable it.
However, you have to get Drupal to know it exists. In some cases, I've had to go to administer >> Site building >> themes, make no changes, and submit the form. Then Drupal recognizes all the themes.
If you see fb_fbml on the blocks admin page, you're ok. If that's the case and you still see garland, its possible I broke something in a recent checkin. If I did, setting the infinite session will solve this for you, and I'll check in a fix soon.
Disable fb_fbml again and report back here if you still have problems.
#2
It was showing up on the blocks page already. The infinite session fixed it. Obviously still need to figure out what broke, though.
#3
I believe you DO need to enable fb_fbml theme. I had the same problem and enabling it (without making it default) fixed the issue.
#4
I actually had had it enabled but that didn't help. Only the infinite session fixed it.
#5
Maybe you have to have it both enabled and have infinite session set ? I did not try without the infinite session...
#6
There are two issues. Right now, you need the infinite session set, only because of a bug which I have a fix for, but is not checked in.
The other issue is that Drupal ignores the custom_theme setting unless it finds our theme in the database. It does not have to be enabled, believe me. But you have to go to the themes list and hit submit, even if you change none of the settings. There's nothing to be done about this.
#7
I have the fbml theme enabled, saved the themes pages, still the facebook page doesnt use it, and the errors show up. I enabled the infinite session modules, but its still broken. If you want to check, here is the page: http://apps.facebook.com/airportcitizen. Also default node links are somewhat broken, but thats a separate issue.
This is the front page of my website on http://airportcitizen.net, which is not a View, but the default Drupal frontpage, with published nodes, maybe that is the problem?
#8
Snufkin I could not visit your app on facebook. Maybe you have the "developer only" box checked?
If you see none of your facebook canvas page, and you get errors along the lines of "html" and "body" tags not allowed in FBML, then the wrong theme is being used.
If you see most of your canvas page, but some errors about some tags not being allowed in HTML, then the problem is not the them, but your content and/or blocks contain some bad tags. If that's the case, you should submit a new issue. But the fix might involve you changing the way your content is displayed on the canvas page. It's pretty easy to set up one view for your site, and another for your canvas pages.
#9
Yes my bad, I forgot about dev only, this is corrected now.
I see the canvas page, but the second occurs:
FBML Error (line 6): illegal tag "meta" under "fb:canvas"
FBML Error (line 7): illegal tag "link" under "fb:canvas"
CSS Error (line 8 char 8): Unrecognized at-rule or error parsing at-rule.
CSS Error (line 9 char 8): Unrecognized at-rule or error parsing at-rule.
CSS Error (line 10 char 8): Unrecognized at-rule or error parsing at-rule.
And the CSS errors repeat a while. I tried to publish a view that contains no blocks, just the list of nodes, using the facebook teaser list. (this is the url to the exposed view: http://airportcitizen.net/airportlist_fb). If i set the theme completely to the fb_fbml theme, the errors disappear. Thats why i thought this is related to this issue.
#10
Has the infinite sessions fix (mentioned above ) been applied?
#11
This error can happen if some code elsewhere in your system is causing the theme to be initialized before fb_initialize() (now fb_init()) is called.
One fix for this is to lower the weight of fb module in your system table.
If that fails to solve it, hunt down the code that is causing theme_init to be called. It could be a call to theme() or drupal_get_path('theme',...). Adding code like the following to theme_init might help you track it down in the logs:
ob_start();
var_dump(debug_backtrace());
$trace = ob_get_clean();
$trace = '<pre>' . check_plain($trace) . '</pre>';
watchdog('debug', "init_theme has chosen $theme, custom_theme is $custom_theme");
watchdog('debug', "init_theme backtrace " . $trace);
#12
Automatically closed -- issue fixed for two weeks with no activity.
#13
For me the infinite session was applied, tried with and without. I do not have the possibility to check the update from David, thanks for the help, I will reopen if i bump into this again.
#14
Hi everyone, I was having loads of problems getting the app page on FB to display anything until I moved the fb_fbml theme to sites/all/themes, fixed all. I'm not sure if this would help with any of the problems mentioned above, but I did find this forum in my attempts to solve my issue, and I do not see that fix/advice mentioned
All the best,
#15
That is a good point.
To all who wish to use these modules: if you can't read the README, you won't be able to make the modules work.
#16
I'm not sure what's in your README, but the one I've got (from fb-5.x-2.x-dev.tar.gz, datestamped 1220529906) says:
So, you must copy the entire theme directory to sites/all/themes, or another of Drupal's themes directories
Moving the theme to a different directory didn't help me. I resolved the issue by enabling the Facebook Application Canvas Pages module, which then adds a drop-down to the node edit page to let you select the theme for FBML pages. Again, this is not in the README - the version I've got says:
Enable the Facebook modules via the drupal admin pages, as usual. You must enable at least fb.module and fb_app.module. You will probably want to enable fb_user and more of the modules as your App needs them.
#17
it works after disabling facebook development module. Thank you very much Dave
#18
You should not need to disable the fb_devel module. If that solves your problem, the root cause is probably that an error is being written to the log (or screen), and than is causing theme_init to be called to soon. Check your log for error messages and solve those errors.
#19
Got it to work by disabling the logo from the fb_fbml theme.
#20
Having the same issue, the one thing I have not tried yet is Dave's code.
What I am also seeing is that if I access the Canvas Callback URL set by the app directly, Firefox warns of an infinite redirect loop. Is that normal?
#21
No that's not normal, that's bad. If you want help open a new issue and post what that URL looks like.
#22
Hi Dave,
Thanks for that.
I resolved the endless loop as I mentioned in another thread, and now I am facing this issue.
Where is this theme_init function where I can add the code?
Has this changed in Drupal 6? :)
PS: nevermind, I found it in another issue:
"Using a text editor, find the function init_theme() in includes/theme.inc. Paste the code into the very end of that function."
I managed to unearth this from my watchdog entry, this was the only one related to theme
[1]=>array(4) {
["file"]=>
string(74) "/nfs/c03/h03/mnt/54365/domains/reviewcritical.com/html/includes/common.inc"
["line"]=>
int(2917)
["function"]=>
string(5) "theme"
["args"]=>
array(2) {
[0]=>
&string(6) "markup"
[1]=>
&array(4) {
["#weight"]=>
int(-101)
["#value"]=>
string(32) "<span class='print-link'></span>"
["#title"]=>
NULL
["#description"]=>
NULL
}
}
}
PS: After digging and searching I found the issue, http://drupal.org/node/451408, holy cow, unbelievable :) That was it. I am disabling the print and pdf links.
#23
#24
Hmm, so I uninstalled the print, pdf and email links module, and now I am seeing another theme call in watchdog, but this is for the actual body text of my front page:
Not sure how to crack this one, as this is via filtered html of the page body, so I have yet to see my page rendered in facebook...
[1]=>array(4) {
["file"]=>
string(74) ".../includes/common.inc"
["line"]=>
int(2917)
["function"]=>
string(5) "theme"
["args"]=>
array(2) {
[0]=>
&string(6) "markup"
[1]=>
&array(4) {
["#weight"]=>
int(0)
["#value"]=>
string(479) "<p>Here is my frontpage text lalalal allala</p>
"
["#title"]=>
NULL
["#description"]=>
NULL
}
}
}
#25
I can't tell from what's posted here what is calling theme_init. You have to scroll down to the function which calls it, or maybe further, to find the real culprit. The idea is if anything calls theme_init before DFF has a chance to set $custom_theme, that code needs to be repaired.