Copied to clipboard

Flag this post as spam?

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


  • Philip Christianto 20 posts 150 karma points
    Sep 04, 2017 @ 14:42
    Philip Christianto
    0

    I want to use a sub domain for the mobile version of the site im making

    so for example it will be m.mysite.com for the www.mysite.com can i just copy everything from the desktop site to the mobile site then change the template to mobile template?

    so that it will actually have the same url except the subdomain like m.mysite.com/about with www.mysite.com/about and if I add content to the main site will it shows in the mobile site given that the database it use will be the same one.

  • Alex Skrypnyk 6054 posts 23213 karma points MVP 5x admin c-trib
    Sep 04, 2017 @ 14:46
    Alex Skrypnyk
    0

    Hi Philip

    You can use the same site and the same content for both sites, but you have to implement some logic that will define what template to use for the current client.

    Look at this code: https://gist.github.com/brendankowitz/4071660

    You need something like that, define what devices is visiting your page and use the needed template.

    Thanks,

    Alex

  • Philip Christianto 20 posts 150 karma points
    Sep 04, 2017 @ 14:57
    Philip Christianto
    0

    Where and how do I implement that?

  • David Armitage 485 posts 2039 karma points
    Sep 05, 2017 @ 11:49
    David Armitage
    0

    Hi Phillip,

    If you have multiple sites (multiple homepages) you need to set a domain for each homepage.

    This can easily be done by right clicking on each homepage node and then clicking on Culture & Hostnames.

    Do this for both and create which ever domain you want to link to each homepage node.

    so

    www.mysite.com - points to homepage1 m.mysite.com - points to homepage2

    enter image description here

  • David Armitage 485 posts 2039 karma points
    Sep 05, 2017 @ 11:51
    David Armitage
    0

    Here is another screen shot of a site where I have done exactly this. As you can see I have a load of different homepages all with different domains pointing to each.

    enter image description here enter image description here

  • Philip Christianto 20 posts 150 karma points
    Sep 05, 2017 @ 12:09
    Philip Christianto
    0

    but this will make the admin have to create a separate content for the mobile site while my mobile site will have exact same content with the desktop site.

    It only need a different template because the position and design of the page will be significantly different between the 2.

  • Alex Skrypnyk 6054 posts 23213 karma points MVP 5x admin c-trib
    Sep 05, 2017 @ 12:58
    Alex Skrypnyk
    0

    Hi Philip

    This is exactly what I recommended you, you have to set mobile and desktop domains to the same root node and add custom logic that will handle which template to choose for the current request.

    Thanks,

    Alex

  • Philip Christianto 20 posts 150 karma points
    Sep 05, 2017 @ 13:04
    Philip Christianto
    0

    i have no idea on how to add the custom logic or where

  • Alex Skrypnyk 6054 posts 23213 karma points MVP 5x admin c-trib
    Sep 05, 2017 @ 13:42
    Alex Skrypnyk
    100

    Philip, try to create custom render controller, something like that:

    public class PageRenderController : RenderMvcController
    {
        public ActionResult Page(RenderModel model)
        {
            if (Request.Browser.IsMobileDevice)
            {
                return View("mobileViewName");
            }
    
            return CurrentTemplate(model);
        }
    }
    

    Read more about render controllers - https://our.umbraco.org/documentation/implementation/Controllers/

  • Philip Christianto 20 posts 150 karma points
    Sep 05, 2017 @ 14:25
    Philip Christianto
    0

    So from what I understand here and the link given,

    The mobileViewName is the template name.

    We need to create a controller for each of the document type.

    Is there no way to redirect all document type to the mobile version instead of making a controller for each one?

    public class HomeController : RenderMvcController
    {
        public override ActionResult Index(RenderModel model)
        {
            //Do some stuff here, then return the base method
            if (Request.Browser.IsMobileDevice)
            {
                return View("mobileViewName");
            }
            return base.Index(model);
        }
    
    }
    
  • Philip Christianto 20 posts 150 karma points
    Oct 16, 2017 @ 12:57
    Philip Christianto
    0

    currently starting to build the mobile template now but i got

    cannot perform runtime binding on a null reference

    on the line

    <title>@CurrentPage.name</title>
    

    any help on how i can use currentpage again?

  • Alex Skrypnyk 6054 posts 23213 karma points MVP 5x admin c-trib
    Sep 05, 2017 @ 14:53
    Alex Skrypnyk
    0

    You can create controller for base document type, it will be for all doctypes nested from this one or another way is to use SetDefaultControllerType-

    public class CustomApplicationEventHandler : ApplicationEventHandler
    {
        protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(MyCustomUmbracoController));
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft