Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • k 256 posts 654 karma points
    May 29, 2017 @ 05:16
    k
    0

    Is it possible to change template for mobile version in umbraco 7

    Hello,

    Is it possible to switch template when we are on mobile version ?

    That is we have a different template for mobiles.

    Thanks for helping.

    kusum

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 29, 2017 @ 09:09
    Alex Skrypnyk
    100

    Hi Kusum

    Yes, it's possible, you have to use RenderMvcController for defining what view to use for the current request, the code will look like that:

    public class HomeController : Umbraco.Web.Mvc.RenderMvcController
    {
        public ActionResult Index(RenderModel model)
        {
            if (Request.Browser.IsMobileDevice)
            {
                return View("mobileDeviceTemplateAlias", model);
            }
    
            return CurrentTemplate(model);
        }
    }
    

    Hope it will help you.

    Thanks,

    Alex

  • k 256 posts 654 karma points
    May 29, 2017 @ 10:27
    k
    0

    Thanks alex for your quick reponse. I will try it :).

Please Sign in or register to post replies

Write your reply to:

Draft