I may be missing something really simple here, but I cannot seem to get the picked media value in a razor expression.
I am using the S3 provider and want to get the media url so I can use it with JW Player. I have a property on my document called "Video" which is a "Amazon S3 File" data type. I can add the video using the picker, but then I render the document using Razor expression @Model.Video the content is rendered as "umbraco.MacroEngines.DynamicXml".
I can see that the value is in the database. I have also tried @Model.Video.Value, @Model.Video.value and I cannot figure it out. How do I get the value of the dynamic xml property?
This has to do with how Razor recognizes the value of the property. In the UMP provider the value is saved as CDATA, which seems to cause a little confusion.
I read that post and was not able to make it work.
This is the content that is stored in the database:
<Lecture id="1136" parentID="1106" level="3" writerID="0"
creatorID="0" nodeType="1102" template="1103" sortOrder="2"
createDate="2011-05-27T22:14:30" updateDate="2011-05-30T10:26:56"
nodeName="Second Lecture" urlName="second-lecture"
writerName="admin" creatorName="admin"
path="-1,1061,1106,1136" isDoc="">
<metaDescription>This is a second lecture</metaDescription>
<bodyText><![CDATA[
<p>Here is the text of the second lecture. Trying to use S3 Streaming!</p>
]]></bodyText>
<galleryID></galleryID>
<video>
<value dataTypeId="1135">
<![CDATA[rtmp.mydomain.com/videos/demo.mp4]]>
</value>
</video>
</Lecture>
Thank you for the suggestion. I had to modify it a little to make it work. This is what I came up with. This probably not the most optimal but let me know if you have any ideas.
Getting the media url in Razor
Hi Justin,
This has to do with how Razor recognizes the value of the property. In the UMP provider the value is saved as CDATA, which seems to cause a little confusion.
See this post for reference on the same issue: http://our.umbraco.org/forum/developers/razor/17897-How-to-iterate-DynamicXml
Sounds like @Model.Video.Value should work though, as Video is the name of your Amazon property.
- Morten
I read that post and was not able to make it work.
This is the content that is stored in the database:
This is my razor template
When ever I render the page I get 'umbraco.MacroEngines.DynamicXml' does not contain a definition for 'Value'. What am I doing wrong?
If I change the template to use
The browser renders
It also does not work if I use @Model.video.value.
Justin,
Here's a quick solution (may not be the most optimal solution...)
which should get you the value of the first <value> node.
Hope this helps.
Regards,
/Dirk
Dirk,
Thank you for the suggestion. I had to modify it a little to make it work. This is what I came up with. This probably not the most optimal but let me know if you have any ideas.
@XDocument.Parse(Model.Video.ToXml()).Element("value").Value
When I called XDocument.Parse(Model.Video) it said that the Parse function had invalid arguments. So that is why I added the ToXml() to the argument.
is working on a reply...