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?

CommentFileSizeAuthor
#10 1298644_d6.patch17.05 KBmkalkbrenner
#9 1298644_d7.patch20.16 KBmkalkbrenner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkalkbrenner’s picture

Have a look at the feature included in ThemeKey to keep a theme for a session until a new rule matches.

frank0051’s picture

Well, 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?

mkalkbrenner’s picture

What 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):

system:referer ! croomsalumni
   system:referer = facebook => facebook theme
   system:dummy = dummy => normal theme

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.

frank0051’s picture

I've give that a try, both suggestions look promising. Thanks for the ideas - I'll report back with any progress made.

frank0051’s picture

So, 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).

mkalkbrenner’s picture

You 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 ! croomsalumni and system:referer = facebook => facebook theme with 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:

system:referer ~ /^((?!croomsalumni\.com).)*$/
     system:referer ~ /facebook/ => facebook theme
     system:dummy = dummy => standard theme
frank0051’s picture

No, that still makes it so the Facebook theme is applied if the user visit the website outside of Facebook.

mkalkbrenner’s picture

What'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

mkalkbrenner’s picture

FileSize
20.16 KB

Here're the new operators for ThemeKey 7.x. 6.x will follow ...

mkalkbrenner’s picture

Title: Is there a way to apply a theme to pages linked on the page? » new operators "*", "!*", "!~"
Project: ThemeKey Properties » ThemeKey
Component: User interface » Code / API
Assigned: Unassigned » mkalkbrenner
Category: support » feature
Status: Active » Needs review
FileSize
17.05 KB

OK, using the patch your rule cascade has to be this:

system:referer !* croomsalumni
     system:referer * facebook >>> facebook theme
     system:dummy = dummy >>> standard theme
mkalkbrenner’s picture

Version: 6.x-3.x-dev » 6.x-4.x-dev

Just try ThemeKey 6.x-4.0-beta1 ...

frank0051’s picture

Installing 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

mkalkbrenner’s picture

Oops!
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 ...

frank0051’s picture

Upgraded 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 :-(

mkalkbrenner’s picture

... 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.

The important part is this:

     system:dummy = dummy >>> standard theme

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".

frank0051’s picture

Ah, 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

if(isset(system:referrer))
{
  if(system:referrs !* croomsalumni){
      if(system:referrer * facebook) => theme=Facebook
      else system:dummy=dummy => standard
  }
}
else system:dummy=dummy => standard
frank0051’s picture

Ah, 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 :-(.

mkalkbrenner’s picture

Ah, I see.

ThemeKey skips a rule if the value is empty. This requires another operator.
Stay tuned ...

mkalkbrenner’s picture

Status: Needs review » Needs work
mkalkbrenner’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.