I am redirecting my site to my mobile theme based on a mobile device, I want users to be able to view the full site with a link in the footer. I have tried to use the drupal:base_path but I'm not having any success...can anyone help my override my themekey mobile theme back to my default theme based on a specific url..?
Thanks fellow drupalers.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkalkbrenner’s picture

drupal:base_path is the wrong property for your needs. I guess you haven't read the manual, right ;-)

drupal:base_path
Drupal: Base path - If Drupal is installed in a subdirectory, the base path will be '/[subdirectory]/', otherwise just '/'. 

Have a look at drupal:path.

Check "Properties explained" for more information.

deelite’s picture

Did you have any success?

Ndesign’s picture

I had a little luck with drupal:path,
I tested this and it seemed to have worked except for the fact that It wont override the conditions I already have set which are:

system:user_os = Iphone (mobile theme)

mkalkbrenner’s picture

If you post a screenshot of your rules we can have a look ...

Ndesign’s picture

FileSize
79.41 KB

thanks mkalkbrenner
Im using m=0 for my drupal:path and placing this key in my url footer link e.g. View Full Site.
I am not matching any specific conditions so I would not need a wildcard? I'm also running Varnish which is hopefully is not tampering with my TK switch.
Sorry for the novice experience and thanks again for your help!

Ndesign’s picture

FileSize
79.12 KB

this is the correct screenshot

mkalkbrenner’s picture

If you enable ThemeKey Debug and trace the rule switching you'll see that ThemeKey switches the theme as soon as a rule matches. Therefore the last rule could not override previous rules. You have to move the path rule on top.

But as indicated by the small icon all your mobile device detection will not work with varnish (or the build-in page cache)!
If you need varnish you have to to run different sub domains like mobile.example.com

Shane Birley’s picture

@mkalkbrenner -- is there a way to switch between subdomains using Themekey? I have been bashing my head to solve this problem without having to involve external modules (browscap, etc). This combined with a way to switch back and forth between mobile and full (while visiting a site from a mobile device) would be a holy grail of Themekey awesomeness.

mkalkbrenner’s picture

@Shane Birley:
You want to redirect the user automatically to the mobile sub domain as soon as he accesses the site with a mobile phone, right?
This needs to be done using javascript to be compatible with site caches.
Beside the javascript we need a small callback function that runs ThemeKey's client detection on drupal side.
Not to much work, but I don't know when I'll find time for that ...

Shane Birley’s picture

@mkalkbrenner --

I suppose my entire dream is to keep the detection, redirection, and ability to flip back and forth "within the Themekey family". What I ultimately want is for:

Themekey to use rule chains to load themes based on platform/browser. (Oh, wait, it does this already! Check!)
Themekey has the ability to switch between domains (www.example.com = desktop, m.example.com = mobile)
Themekey somehow controls the request for different theme (like the mobile viewers wanting the desktop theme via a link or allowing desktop visitors to view mobile theme via a link) per session, time, cookie, or anything else that makes sense. This would need a bit more fleshing out, I think.

Some of the ideas above have some from other users around the support forums and also a few other modules that "almost" do what most people seem to want.

I have tinkered with Simple Mobile Redirect a bit to see if it would work with Themekey and it "sort of" worked. I felt that the detection wasn't great (as Themekey does a better job) but felt that some sort of integration of that code into Themekey may be worth checking out. It already does the auto detection/selection of a theme but it may be far better to integrate some of that either into rule chains somehow. I thought it may be interesting to introduce "if/else" loops into rule chains or some other operators to allow for similar choices. I feel integrating the functions into Themekey directly would answer a lot of people's questions that I keep running into all over the issue queues for various mobile related modules.

There is my brain dump on this subject. I think I covered everything but possibly not. I may add a few more thoughts as they come to me but I am very much open to anyone's thoughts on this as well.

I do have a small budget/bounty to help get this code written (if you think it is possible). Or if you know of someone who is a maintainer and has some time?

Shane Birley’s picture

@mkalkbrenner -

Is there anything I can do to help out? (Said the squeaky wheel.)

mkalkbrenner’s picture

@Shane Birley:
I thought about your feature request and think it's possible to provide it as add-on packaged with ThemeKey. The question is when do you need it and if I find some free time soon enough. Maybe you should contact me using my contact form on drupal.org.

Shane Birley’s picture

Sorry! Was distracted with family wedding stuff and then promptly started fighting a summer cold. Great stuff. Do you need anything from me at this point?

mkalkbrenner’s picture

Title: Redirect to live site from mobile » redirect to different (sub-) domain by rule
Version: 7.x-2.3 » 7.x-3.x-dev
Assigned: Unassigned » mkalkbrenner
Category: support » feature
Status: Active » Needs work

I just committed the first prototype to 7.x-3.x dev.

If you enable the new sub-module ThemeKey Redirect you'll recognize a new tab called "Redirecting Rule Chain". There you could define any rule you like and targets where the user should be redirected to if a rule matches. The implementation should play well with page caches if the client supports/enabled javascript!

The feature still requires some optimization:

  • optionally store the redirect event in a cookie on the client's side as final to avoid the additional ajax call on every page.
  • provide configuration if a redirect should hit the target exactly like configured or if the deep link gets applied.
  • optionally provide a block with links to let the user explicitly select the desktop version instead of the mobile one.
  • Features support to export / import rules
ksavoie’s picture

I am testing 'Redirect Rule Chain' and it looks to be exactly what I require except for this odd behavior.

My site resides at
http://www.mycompany.com/myDsite
(b.t.w. this is my what my $base_url is set at if it has any bearing)

I have a redirect rule set to redirect to this TARGET
http://mycompany.supportcompany.com

When it redirects it tries to go to the following.
http://mycompany.supportcompany.com/myDsite/?themekey_redirect=active
Which errors as that path doesn't exist.

Why does it drop the sub-directory and additional parameter at the end of the TARGET?
Is there a way around this?

Thanks for any assistance.

mkalkbrenner’s picture

The parameter themekey_redirect=active should not hurt you. It is required to avoid an endless redirect loop, if the targeted site runs Drupal/ThemeKey as well.

If the path /myDsite is correct depends on your use case. For Shane Birley's use case it is correct. But I already mentioned that in comment #14:

provide configuration if a redirect should hit the target exactly like configured or if the deep link gets applied.

I hope to find some time to complete the tasks mentioned in #14. When do you need that feature?

ksavoie’s picture

mkalkbrenner thanks for the reply.

In my use case this behavior won't work as the http://mycompany.supportcompany.com is a completely independent company that is supplying mobile services for my clients users thus I have no control over how their system responds. I understand why you may need to pass the parameter but the addition of the sub-directory needs to be optional at best. Maybe checkbox or an expression in the TARGET that can be searched that would toggle this behavior. (i.e. http://mycompany.supportcompany.com$1 )

As for "When do you need that feature?", ASAP would be my canned answer : ) as I am replacing 'Simple Mobile Redirect' on a production site due to it's bugs.

Thanks for your attention to this!

>>UPDATE<<
Until a more elegant solution is implemented I have found a workaround that worked in my case.
In the TARGET I added "/?null=" to the end of the url. This makes anything added to the end appear to be a passed parameter. In my case the receiving server just ignores it (your mileage may vary).

I also set up a mechanism for mobile switching to be disabled via a url.
FIRST I put this at the top of my template.php file.
[ To be honest I'm not sure if this code would be more appropriately handled within a hook ]

//  MOBILE SESSION MANAGEMENT
if (!empty($_REQUEST['nomobi'])) {
	// param was set in the query string
	if ($_REQUEST['nomobi'] == 'true') {
		// disable mobile switch
		$_SESSION['nomobi'] = '1';
	} else {
		// re-enable mobile switch
		$_SESSION['nomobi'] = '0';
	}
} else if (!isset($_SESSION['nomobi'])) {
	// default mobile switch to enabled
	$_SESSION['nomobi'] = '0';
}
//  /MOBILE SESSION MANAGEMENT

Then I configured the following 'Redirecting Rule Chain'

system:session | < | nomobi=1
    system:user_os_simplified | = | iPhone | http://mycompany.supportcompany.com/?null=
    .... what ever additional rules you want ....

This lets you pass a url param back to the site that will set a session to ignore theme/rule chain switching by passing the param 'nomobi=true' to the end of the URL (i.e. www.myCompany.com/?nomobi=true).
This then maintains that directive until either the session ends or it is explicitly disabled by passing any other value into 'nomobi' (i.e. www.myCompany.com/?nomobi=X).

Hope this helps some people out.

mkalkbrenner’s picture

@ksavoie: It's ok if it works for you. But I don't recommend your workaround because it uses the session and therefor disables page caching!

ksavoie’s picture

Do you have another suggestions?

b.t.w. for my own education, can you explain how my solution disables page caching?

Also, I believe I discovered a bug in the Redirect Module when using with IMCE.
With it activated and you attempt to upload a file the 'File Browser' popup will open but "Upload | Thumbnails | Delete | Resize" links are missing from the top.
The page throws the following error.
TypeError: $.cookie is not a function
var state = $.cookie('themekey_redirect_state');
- themekey_redirect.js (line 2)

Until worked out, I put a 'try' statement around the whole themekey_redirect.js coding

mkalkbrenner’s picture

Status: Needs work » Needs review

@ksavoie: Id you store something in the session for anonymous users, drupal turns of page caching and treats these users like logged in users.

I just committed the "append path" switch, which could be configured per rule in the chain: http://drupalcode.org/project/themekey.git/commit/8bdb20c

Your workaround is not required anymore.

I also fixed the javascript bug you discovered:
http://drupalcode.org/project/themekey.git/commit/8d78559

I had a script in my dev setup that always added jquery.cookie! Thanks for finding that issue!

@Shane Birley; This might be the reason for the strange behavior in your setup as well!

@ksavoie @Shane Birley: Can you test the redirect module once again?

ksavoie’s picture

mkalkbrenner:
I think that you are working in the right directions but am seeing the following behavior.

1) when initially installed I received a slew of "Notice: Array to string conversion in" across several modules, then again when viewing content. but now no longer display
2) the append redirect toggle seems to be working (great!)
3) when activating IMCE popup, This error dialog displays briefly then fades away and IMCE appears to function properly.

An AJAX HTTP error occurred.
HTTP Result Code: 404
Debugging information follows.
Path: /themekey/redirect_callback/mydevsite/imce?app=ckeditor%7Csendto%40ckeditor_imceSendTo%7C&CKEditor=edit-body-und-0-value&CKEditorFuncNum=111&langCode=en
StatusText: Not Found
ResponseText:
404 Not Found
Not Found
The requested URL /themekey/redirect_callback/mydevsite/imce was not found on this server.
Apache/2.2.3 (CentOS) Server at dev.mydevserver.com Port 80

Let me know if I a can offer any additional debug.

mkalkbrenner’s picture

Status: Needs review » Needs work

Thanks for testing!

I guess you installed drupal in a folder called mydevsite, right?

And the javascript is not working if you did not enable "clean urls".

I'm working on it ...

mkalkbrenner’s picture

Status: Needs work » Needs review

I just committed http://drupalcode.org/project/themekey.git/commit/57c422c to (hopefully) fix the imce problem. Can you test it?

ksavoie’s picture

Looks like it's going to work! No Errors. : )
Thanks for your work.

Any suggestions on alternative methods of redirect management other than my _SESSION solution?

mkalkbrenner’s picture

Did you try the 'ThemeKey Redirect Domain Selector' Block provided by ThemeKey Redirect?
I think it provides the logic you need but uses a cookie instead the session.
The behavior of that block is configurable!

mkalkbrenner’s picture

Issue summary: View changes
Status: Needs review » Fixed

The features are done. Therefor I set this feature request to fixed. For support requests or bugs you should open new issues.

Status: Fixed » Closed (fixed)

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