Detect iPhone users with Radiant Language Extension

picture-10

if you are a big fan of Radiant CMS (like we are) probably you are using Language Extension for redirecting your visitors to appropriate language pages.
How about redirecting iPhone users to an iPhone-only version of your site?

Today my teammate Volkan Caliskan launched iPhone-only site of Vayen and shared me a trick that They have found with my friend Mert Yentur,

Here comes the trick for redirecting iPhone users to a specific web page with Radiant Language Extension.
open your /vendor/extensions/language_redirect/app/models/language_redirect_page.rb
then change location method like:

def location
path = nil
languages.find do |lang|
path = location_map[lang[0..1]]
end
path ||= location_map["*"] || ‘/en/’
if (@request.user_agent.include?(”iPhone”)==true)
then
path = “http://www.vayentech.com/iphone/”
end
if path =~ %r{[:][/][/]}
path
else
@request.protocol + @request.host_with_port + path
end
end

as you’ve noticed, we have only added following lines, nothing more.

if (@request.user_agent.include?(”iPhone”)==true)
then
path = “http://www.vayentech.com/iphone/”
end

Hope this trick helps radiant fans :)
thanks to Volkan Caliskan & Mert Yentur for sharing the trick.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Post Metadata

Date
August 3rd, 2009

Author
Guvener Gokce

Category

Tags


Leave a Reply