Okay, I don't know if the title made any sense, so I will provide an example. I have a default theme and a "Facebook" theme. Using the ThemeKey rule "system:query_param" I am able to set the theme whenever the $_GET includes "facebook".
For example: when http://www.croomsalumni.com/about/board is the default theme whereas http://www.croomsalumni.com/about/board?facebook is the the "Facebook" theme. The problem I'm having is that when the user clicks a link while using the "Facebook" theme, the new page is the default theme. Do you have any suggestions on how to fix this? Perhaps there is a way to pass the GET variable?
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 1298644_d6.patch | 17.05 KB | mkalkbrenner |
| #9 | 1298644_d7.patch | 20.16 KB | mkalkbrenner |
Comments
Comment #1
mkalkbrennerHave a look at the feature included in ThemeKey to keep a theme for a session until a new rule matches.
Comment #2
frank0051 commentedWell, that is a temporary fix, but the problem is when they visit the site outside of Facebook, the theme isn't switched to the normal theme. Too bad Drupal for Facebook does not work properly. Any other suggestions?
Comment #3
mkalkbrennerWhat about checking the referer for "facebook" using system:referer and a regular expression (~)?
So you have a rule set like this (with the session feature enabled):
Another alternative:
set a cookie with a short time to live like 10 Minutes and prolong it on every page request. Use system:cookie to check for it's existence.
Comment #4
frank0051 commentedI've give that a try, both suggestions look promising. Thanks for the ideas - I'll report back with any progress made.
Comment #5
frank0051 commentedSo, the system:referrer seems to work one level in. For instance when an individual clicks the custom tab, the referrer is indeed Facebook. Since my custom tab is target defined using page?facebook (using ThemeKey to switch the theme), the referrer when the user clicks a link is page?facebook and Facebook is found when running system:referrer using ~ 'facebook'. Now, after clicking the link, if you the user were to click another link, the referrer becomes my site without the ?facebook appended and the rule no longer applies.
A cookie might be the best option at this point unless Facebook for Drupal gets its act together or I can find a way to pass that $_GET variable onto each link (or, alternatively, pass it as a $_POST).
Comment #6
mkalkbrennerYou didn't setup the rules like I suggested.
1. The sessions feature is still required for the referer approach
2. you have to replace
system:referer ! croomsalumniandsystem:referer = facebook => facebook themewith real regular expressions.3. delete any other rules
This is the rule chain in words:
If referer is not my own site croomsalumni.com
and referer contains"facebook" => switch theme to facebook and store it in session
If referer is not my own site croomsalumni.com
and referer does not contain "facebook" => switch to default theme and store it in session
If no rule of the ones above match use theme from session.
Translated into ThemeKey rules it should mostly look like this:
Comment #7
frank0051 commentedNo, that still makes it so the Facebook theme is applied if the user visit the website outside of Facebook.
Comment #8
mkalkbrennerWhat's the output of ThemeKey Debug for system:referer if you click on the first link after you came from facebook?
BTW I know that the "negative" regex for "not croomsalumni" isn't that easy. I'm preparing three new operators:
* contains
!* not contains
!~ not matching regex
Comment #9
mkalkbrennerHere're the new operators for ThemeKey 7.x. 6.x will follow ...
Comment #10
mkalkbrennerOK, using the patch your rule cascade has to be this:
Comment #11
mkalkbrennerJust try ThemeKey 6.x-4.0-beta1 ...
Comment #12
frank0051 commentedInstalling Beta 4, just wanted to let you know that it is generating a warning on the update.php page:
"warning: Cannot modify header information - headers already sent by (output started at /home/crooms/public_html/sites/all/modules/themekey/themekey_admin.inc:3) in /home/crooms/public_html/includes/common.inc on line 147."
Update: Actually, it won't update. Generates a white page with this text: + '*' => '*', + '!*' => '!*',
Same thing happens when I try to disable a themekey entry using Beta 4
Comment #13
mkalkbrennerOops!
Seems like I copied and pasted some lines of the ThemeKey 7 patch at the top of themekey_admin.inc just before committing. Thanks for your feedback!
Just released 6.x-4.0-beta2 ...
Comment #14
frank0051 commentedUpgraded fine, no problems with the operators and it works down multiple links into the Facebook iFrame, but he problem is still the same: if the user decides to visit the actual site on the same browser, the theme doesn't switch to the system default. It think I'll just have to keep poking Facebook for Drupal's maintainers to get their version of the feature to work properly :-(
Comment #15
mkalkbrennerThe important part is this:
This one should set the the theme to non-facebook if the user revisits your site later.
I guess you're using "System default" as theme in this rule? This won't work in combination with the session feature. You have to set the the explicit, p.e. "Garland".
Comment #16
frank0051 commentedAh, I've found the problem: the chain doesn't evaluate when referrer is blank. For instance: it works inside the iframe, it also works if I open a new tab (which is still the same session) and search for the site on Yahoo! (the referrer is Yahoo!), but if I open a new tab and browser to the site on my own, the referrer is blank.
Is there a way to add an overarching rule we can add to the chain so it would look like
Comment #17
frank0051 commentedAh, but thinking about it, that would kill the retaining properties multiple links in because it explicitly sets a new theme.
Argh, stupid Facebook for Drupal not working property. Please feel free to quit trying, this isn't your problem :-(.
Comment #18
mkalkbrennerAh, I see.
ThemeKey skips a rule if the value is empty. This requires another operator.
Stay tuned ...
Comment #19
mkalkbrennerComment #20
mkalkbrenner