Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
sharimi zainuddin
mobile web
April 1, 2013 8:45 PM
Answer

sharimi zainuddin

Rank: New Member

Posts: 9

Join Date: April 9, 2012

Recent Posts

Hi dear community members,
I've put some code in my init_custom.vm to redirect users who use smart phone to my mobile web...
The problem is that I can't redirect from mobile web to portal back...
Below is my code...
Any Idea how to redirect from mobile web to portal...?

#set ($isIphone = $request.getHeader("User-Agent").toLowerCase().indexOf("iphone") != -1)
#set ($isIpad = $request.getHeader("User-Agent").toLowerCase().indexOf("ipad") != -1)
#set ($isAndroid = $request.getHeader("User-Agent").toLowerCase().indexOf("android") != -1)
#set ($isMobile = $request.getHeader("User-Agent").toLowerCase().indexOf("mobile") != -1)

#set ($isMobileDevice = ($isIphone||$isIpod ||$isIpad ||$isBlackBerry ||$isAndroid ||$isMobile))

#if ($isMobileDevice)
<script type="text/javascript">
window.location.href = "http://www.mdpputeh.gov.my/mobile";
</script>
#end
Jitendra Rajput
RE: mobile web
April 1, 2013 10:32 PM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 824

Join Date: January 7, 2011

Recent Posts

Instead of writing your logic in vm file you can use ServicePreAction for the same. There are also use full API's available in liferay for device detection.


1   if (BrowserSnifferUtil.isMobile(request) || BrowserSnifferUtil.isWap(request)
2                || BrowserSnifferUtil.isIphone(request))
3        {
4
5    response.sendRedirect() // redirect to your specific page.
6}
sharimi zainuddin
RE: mobile web
April 1, 2013 10:42 PM
Answer

sharimi zainuddin

Rank: New Member

Posts: 9

Join Date: April 9, 2012

Recent Posts

Thank you for your respon Jitendra Rajput...
So where do i find this ServicePreAction...
Jitendra Rajput
RE: mobile web
April 1, 2013 11:09 PM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 824

Join Date: January 7, 2011

Recent Posts

Which version of Liferay you are using . ?
if 6.x then you can override your serviceAction using hook . Check this blog
sharimi zainuddin
RE: mobile web
April 2, 2013 12:49 AM
Answer

sharimi zainuddin

Rank: New Member

Posts: 9

Join Date: April 9, 2012

Recent Posts

I'am using Liferay 6.0...