How does a content type know which view it is assi...
# help-with-umbraco
m
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?
h
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
m
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"
h
at the top of your view you should see something like
Copy code
cs
@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
m
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); }
how do I paste code? 😄
2 Views