Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 445 posts 1059 karma points
    Jan 10, 2017 @ 15:35
    Ayo Adesina
    0

    Two Websites, One Umbraco Instance - Ideas Please

    I have got a new project that involves two domains, pointing to the same Umbraco Instance.

    Depending on which domain the end user comes through, I want to be able to show them slightly different content.

    Essentially the content will be exactly the same, its just on some pages that content will be different.

    I have built a prototype that works pretty well, for every node I have in the content tree, I have a child node with the exact same properties as its parent.

    If there is a value in the child node, this value is used if end user has come to the site on the secondary domain.

    One of the requirements is, if the content is exactly the same on both domains then the content should only be managed in one node.

    This is an example of the home page. - What do you guys think?

        public class DefaultHomePageController : Umbraco.Web.Mvc.RenderMvcController
    {
        // GET: DefaultHomePage
        public ActionResult Index(RenderModel model)
        {
            var domain = HttpContext.Request.Url.Host;
            var homePageModel = new HomePageModel();
    
            //Get Default Data for defult domain
            homePageModel.IntroductionHeading = model.Content["introductionHeading"].ToString();
            homePageModel.IntroductionText = model.Content["introductionText"].ToString();
            homePageModel.IntroductionImageURL = Umbraco.TypedMedia(model.Content["introductionImage"].ToString()).Url;
    
            //If we have come from the secondary domain lets overwirte the values we find in the child node
            if (domain.ToLower() == "seconddomain.local")
            {
                var secondDomainContent = model.Content.Children.First();
    
                if (secondDomainContent.HasValue("introductionHeading"))
                {
                    homePageModel.IntroductionHeading = secondDomainContent.GetPropertyValue("introductionHeading").ToString();
                }
                if (secondDomainContent.HasValue("introductionText"))
                {
                    homePageModel.IntroductionText = secondDomainContent.GetPropertyValue("introductionText").ToString();
                }
                if (secondDomainContent.HasValue("introductionImage"))
                {
                    homePageModel.IntroductionImageURL = Umbraco.TypedMedia(secondDomainContent.GetPropertyValue("introductionImage").ToString()).Url;
                }
            }
    
            return View(homePageModel);
        }
    }
    

    enter image description here

    If there a better approach? any Ideas?

  • 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