Copied to clipboard

Flag this post as spam?

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


  • k 255 posts 652 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 5908 posts 22603 karma points MVP 4x admin c-trib
    May 29, 2017 @ 09:09
    Alex Skrypnyk
    0

    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 255 posts 652 karma points
    May 29, 2017 @ 10:27
    k
    0

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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies