Hi,
I've encountered a rather strange bug on a client's site. They are using Organic Groups with custom themes and had Nodewords basic running for quite some time. Recently they needed the ability to control what's shared on Facebook, so we enabled nodewords_og. Doing so resulted in all groups with custom themes showing the main site theme.
I was able to trace the problem down to nodewords_og_nodewords_tags_info()
. Not sure what exactly is happening as:
- adding a
return
at the beginning of the function brings back the custom themes - we suspected it may be a namespace conflict, OG API coincidence with the tags callbacks, but renaming them didn't work.
- renaming the module to nodewords_opengraph and replacing all "og" occurrences other than the actual tags to "opengraph" did not help either
The way OG works is by determining the context in hook_init()
and if the user is on a OG, it sets the theme to the group's theme by changing the global variable $custom_theme
among other things. To determine context, it calls node_load()
. Normally all this happens before the theme layer kicks in, so init_theme()
can pick up any changes to $custom_theme
However, nodewords implements hook_nodeapi()
and it is in $op == 'load'
where it tries to load all its tags. And somehow this triggers init_theme()
before OG sets its context and custom theme.
The only solution I could find was to change $op
from "load" to "view", but I am not sure what the implications on other modules are.
Any ideas?
Thank you,
Dan
Comment | File | Size | Author |
---|---|---|---|
#16 | nodewords-og-theme-fix-1986230-16.patch | 986 bytes | zerolab |
#13 | nodewords-og-theme-fix-1986230-13.patch | 1 KB | zerolab |
#8 | nodewords-n1986230-8.patch | 616 bytes | DamienMcKenna |
Comments
Comment #1
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedThis seems to affect people using admin themes too. Our admin theme is not used in various places node/*/edit for example.
Comment #2
kepford CreditAttribution: kepford commentedI can confirm that this issue exists outside of Organic Groups. I was able to reproduce this with both themekey module and a custom theme switching module.
Comment #3
DamienMcKennaDoes this also happen if the 'nodewords_extra' submodule is enabled instead of the OG submodule?
Comment #4
kepford CreditAttribution: kepford commentedNo, the issue does not occur with nodewords_extra enabled.
Comment #5
DamienMcKennaI have a testbed with the Nodewords dev release, Themekey and the following other modules:
The theme selection works just fine with the default Themekey settings and a configuration that changes the theme for a specific content type.
Could you please test out Nodewords v1.15-beta1 to see if that makes any difference?
Comment #6
DamienMcKennaOther than a namespace conflict purely because the module is named "nodewords_og" (thus matches the string "{$modulename}_og"), I don't see how this could be caused by Nodewords. I'm changing the status to Postponed until someone can show otherwise.
Comment #7
DamienMcKennaSo it turns out that the problem is because of module weights, the solution is to change the weight of the ThemeKey module until the switching starts working again. Check out #754970: Skipped rule checking because another module already initialized the theme engine for a long discussion about it. Thanks to kepford for finding that one.
Comment #8
DamienMcKennaI'm going to add this note to the README.txt file.
Comment #9
DamienMcKennaCommitted.
Comment #11
DamienMcKennaComment #13
zerolab CreditAttribution: zerolab at Torchbox for The Chartered Society of Physiotherapy commentedHi,
I know this has been marked as closed for a while now, but changing weights did not solve the issue in the Organic Groups context.
Finally got some time to revisit this and found the issue:
nodewords_og_get_tags()
uses a%count
token for the "og:description" description. As per https://api.drupal.org/api/drupal/includes%21common.inc/function/t/6, "%variable: escape text and theme as a placeholder for user-submitted content (check_plain + theme_placeholder)" -- thus triggersinit_theme()
Attaching patch that changes
%count
to@count
which fixes the issue.Comment #14
DamienMcKenna@zerolab: Nice catch, thanks.
Comment #16
zerolab CreditAttribution: zerolab at Torchbox for The Chartered Society of Physiotherapy commentedAttaching a patch rolled against 6.x-1.x, rather than 1.14
Comment #17
zerolab CreditAttribution: zerolab at Torchbox for The Chartered Society of Physiotherapy commentedComment #18
DamienMcKennaThank you for taking the time to work on this. However, the module is no longer supported, so I'm closing this issue.