Blog about tips & tricks for CMS enhancement

eric.petersson

Multilingual logic with Vorto in Controllers


Here is a very simple way if you've been using Vorto extensions in your Umbraco project and would like to move the view logic to traditional MVC Controller for better code management:

using Our.Umbraco.Vorto.Extensions;
using System.Web.Mvc;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;

public class StartPageController : RenderMvcController
    {
        public override ActionResult Index(RenderModel model)
        {
            var startPage = model.Content;
            var viewModel = new StartPageViewModel(startPage)
            {
                MainTitle = startPage.GetVortoValue<string>("mainTitle")
            };
            return base.Index(viewModel);
        }
    }

Since RenderModel inherits from IPublishedContent (which Vorto also does) you may chain this to your custom view model usage.