Umbraco Jet (uJet) is a Code First approach to building MVC applications in Umbraco 7. Declare your document, media, member, and data types in code, and have uJet move them into Umbraco for you - simplifying development, deployment and versioning.
uJet is capable of serving you with instances of your document types. With uJet you're no longer bound by the RenderModel
, or by the constraints set by the built-in ControllerActionInvoker
. uJet brings you strongly typed views without you having to roll your own view models.
uJet is a developer tool for Umbraco 7, released as Open Source (MIT). It supports document types and media types (including inheritance and composition), member types, data types, and template synchronization.
Online documentation can be found at http://ujet.readthedocs.io/.
PM> Install-Package uJet
uJet is easy to use. Add a reference to uJet to your Umbraco application. Then create your types and decorate them using the DocumentType
, MediaType
, MemberType
, and DataType
attributes. Fire up your application and all of your types will now be available in the Umbraco back office.
- Get, compile, and reference the source code - or use the NuGet.
- Create a model; in this case a document type. Use data annotations for editorial support (e.g. validation and defaults) in the back office.
- Create a view. Name it according to the action method defined in the controller,
Views\MyPage\Index.cshtml
. - Create a controller inheriting from
Logikfabrik.Umbraco.Jet.Web.Mvc.JetController
. - Run your application and log in to Umbraco. The document type My page should now be available. Pages you create using this document type will all be handled by the
MyPageController
. It's that easy!
Model
namespace Example.Models
{
using System.ComponentModel.DataAnnotations;
using Logikfabrik.Umbraco.Jet;
[DocumentType(
"My page",
Description = "Document type for my page",
AllowedAsRoot = true)]
public class MyPage
{
[ScaffoldColumn(false)]
public string Name { get; set; }
[Display(
Name = "Description",
Description = "A short description of my page",
GroupName = "My group",
Order = 100)]
[Required]
public string Description { get; set; }
}
}
View
@model Example.Models.MyPage
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>@Model.Name</h1>
<p>@Model.Description</p>
</body>
</html>
Controller
namespace Example.Controllers
{
using System.Web.Mvc;
using Logikfabrik.Umbraco.Jet.Web.Mvc;
using Models;
public class MyPageController : JetController
{
public ActionResult Index(MyPage model)
{
return View(model);
}
}
}
uJet is Open Source (MIT), and you’re welcome to contribute!
If you have a bug report, feature request, or suggestion, please open a new issue. To submit a patch, please send a pull request.