Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#6 | Screen Shot 2012-12-18 at 10.49.24 AM.png | 79.12 KB | Ndesign |
#5 | Screen Shot 2012-12-18 at 10.31.42 AM.png | 79.41 KB | Ndesign |
Comments
Comment #1
mkalkbrennerdrupal:base_path is the wrong property for your needs. I guess you haven't read the manual, right ;-)
Have a look at drupal:path.
Check "Properties explained" for more information.
Comment #2
deelite CreditAttribution: deelite commentedDid you have any success?
Comment #3
Ndesign CreditAttribution: Ndesign commentedI 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)
Comment #4
mkalkbrennerIf you post a screenshot of your rules we can have a look ...
Comment #5
Ndesign CreditAttribution: Ndesign commentedthanks 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!
Comment #6
Ndesign CreditAttribution: Ndesign commentedthis is the correct screenshot
Comment #7
mkalkbrennerIf 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
Comment #8
Shane Birley CreditAttribution: Shane Birley commented@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.
Comment #9
mkalkbrenner@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 ...
Comment #10
Shane Birley CreditAttribution: Shane Birley commented@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?
Comment #11
Shane Birley CreditAttribution: Shane Birley commented@mkalkbrenner -
Is there anything I can do to help out? (Said the squeaky wheel.)
Comment #12
mkalkbrenner@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.
Comment #13
Shane Birley CreditAttribution: Shane Birley commentedSorry! 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?
Comment #14
mkalkbrennerI 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:
Comment #15
ksavoie CreditAttribution: ksavoie commentedI 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.
Comment #16
mkalkbrennerThe 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:I hope to find some time to complete the tasks mentioned in #14. When do you need that feature?
Comment #17
ksavoie CreditAttribution: ksavoie commentedmkalkbrenner 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 ]
Then I configured the following 'Redirecting Rule Chain'
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.
Comment #18
mkalkbrenner@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!
Comment #19
ksavoie CreditAttribution: ksavoie commentedDo 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
Comment #20
mkalkbrenner@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?
Comment #21
ksavoie CreditAttribution: ksavoie commentedmkalkbrenner:
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.
Comment #22
mkalkbrennerThanks 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 ...
Comment #23
mkalkbrennerI just committed http://drupalcode.org/project/themekey.git/commit/57c422c to (hopefully) fix the imce problem. Can you test it?
Comment #24
ksavoie CreditAttribution: ksavoie commentedLooks 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?
Comment #25
mkalkbrennerDid 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!
Comment #26
mkalkbrennerThe features are done. Therefor I set this feature request to fixed. For support requests or bugs you should open new issues.