#How does a content type know which view it is assigned to?

1 messages · Page 1 of 1 (latest)

short pasture
#

Very beginner question. I want to add a document / content type which has a Youtube link and size of the video. I have been able to create the content type (so that it asks the user for the URL etc), but where do I set what "view" is associated to this content type?

trim turtle
#

The view used is the Template assigned to the document type, if you have more than one template for the document type then you can select which one to use on the "info" section for the node

short pasture
#

so in my case I will have a single view "youtube.cshtml" with the html markup, I then need to inject the url and size from the document type / property editors - Fortunately I have a working version of the site but I couldnt figure out where the "link" takes place to say "this data will be injected into this view / template"

trim turtle
#

at the top of your view you should see something like

@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.YOURMODELNAME>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;

This gives you access to your nodes data, you can then use Model.MyProperty to get the values to assign for link/size etc

short pasture
#

Hmm this is the one I ahve from the previously working view: @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@{
var nodeId = int.Parse(ViewData["id"].ToString());
var node = Umbraco.Content(nodeId);
}

#

@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
@{
var nodeId = int.Parse(ViewData["id"].ToString());
var node = Umbraco.Content(nodeId);
}