I am working in Umbraco 7. I am attempting to use the Datatype: File Upload in an existing template. I have created a custom data type and I have also applied the datatype to the Document Type . I am sure how to go about applying the Datatype to the template so that when an image is uploaded in the content section, it appears in the rendered version of the template when previewed or published.
If anyone can provide assistance I would greatly appreciate your time and consideration.
if you stick the upload property directly onto a document type instead of using a Media Picker, it will go something like this.
@{
var imageRelPath = Model.Content.GetPropertyValue<string>("uploadAlias");
}
<img src="@imageRelPath" alt="stuff" />
Or maybe like this if you like using the dynamic stuff. Forgive me if this is off a bit. I prefer the more strongly typed IPublishedContent over the dynamics, so I'm way out of practice.
CurrentPage and Model.Content will both get you the current node. The first is as a dynamic. The second is as an IPublishedContent.
The best way to go about figuring this sort of stuff out is to change the "Type" of the upload property on your document type into a Label. Doing so will not cause any data loss, but will change your property into a "read only" property editor that renders the raw data stored in the DB.
Below is a screenshot of the Upload data stored in the database. Once you know what the data looks like, you can tell if you should just get it as a raw string or if it is something more complicated like some JSON.
Configuring Datatypes: File Upload*
I am working in Umbraco 7. I am attempting to use the Datatype: File Upload in an existing template. I have created a custom data type and I have also applied the datatype to the Document Type . I am sure how to go about applying the Datatype to the template so that when an image is uploaded in the content section, it appears in the rendered version of the template when previewed or published.
If anyone can provide assistance I would greatly appreciate your time and consideration.
Thanks.
if you stick the upload property directly onto a document type instead of using a Media Picker, it will go something like this.
Or maybe like this if you like using the dynamic stuff. Forgive me if this is off a bit. I prefer the more strongly typed IPublishedContent over the dynamics, so I'm way out of practice.
CurrentPage
andModel.Content
will both get you the current node. The first is as a dynamic. The second is as an IPublishedContent.The best way to go about figuring this sort of stuff out is to change the "Type" of the upload property on your document type into a Label. Doing so will not cause any data loss, but will change your property into a "read only" property editor that renders the raw data stored in the DB.
Below is a screenshot of the Upload data stored in the database. Once you know what the data looks like, you can tell if you should just get it as a raw string or if it is something more complicated like some JSON.
is working on a reply...