OK, so I've managed to get a simple example using NodeById working...but MediaById does not.
@inherits umbraco.MacroEngines.DynamicNodeContext
@{ var children = @Model.NodeById(1074).DescendantsOrSelf(); } @foreach (var item in @children) { @item.Name }
@{ var mediaFolder = @Model.MediaById(1198).DescendantsOrSelf(); } @foreach (var item in @mediaFolder) { @item.Name }
The above razor script (cshtml) shows a loop through nodes which successfully outputs the name of all descendants below the hard coded node id (via NodeById)
However the second statement (MediaById) throws an error as'umbraco.MacroEngines.DynamicMedia' does not contain a definition for 'DescendantsOrSelf'. I've also tried 'Children' instead of DescendantsOrSelf but that throws the same error.
I am having an issue with getting media to display using a .net user control. I have a node called currentPage (which is the current page), then I go through each child page and get all of the childrens' "properties." I use those properties to display certain content on the current page, and one of those properties that I need to display is the child page's "mediaArea" (which is the alias). mediaArea contains the image(s) that I am trying to display on the parent page, but I just don't know how to do it using .net user controls. The current code that I am trying to use to display the images looks like this: sw.WriteLine(string.Format(@"<img src=""{0}"" />", child.GetProperty("mediaArea").Value));, where sw is my StringWriter. Anyone have any suggestions?
Extract media with certain property values
I cannot figure this out.
I have memberId as a property in the image media type. Ideally, I want to putt out all images with a certain memberId.
If these were documents, I could use something like this...
I've found documentation on DynamicMedia and MediaById - but I cannot get these working at all.
Any help would be much appreciated.
NOTE I'm using 4.7RC
OK, so I've managed to get a simple example using NodeById working...but MediaById does not.
The above razor script (cshtml) shows a loop through nodes which successfully outputs the name of all descendants below the hard coded node id (via NodeById)
However the second statement (MediaById) throws an error as'umbraco.MacroEngines.DynamicMedia' does not contain a definition for 'DescendantsOrSelf'. I've also tried 'Children' instead of DescendantsOrSelf but that throws the same error.
Any idea of how to get Children of Media?
The children helper methods (Descendants, Children etc) are only implemented on DynamicNodeList/DynamicNode, not on DynamicMedia
We intentionally didn't implement these because Media isn't cached, and as a result, you'd end up with performance problems.
I'll think about the best way to solve this prob
I am having an issue with getting media to display using a .net user control. I have a node called currentPage (which is the current page), then I go through each child page and get all of the childrens' "properties." I use those properties to display certain content on the current page, and one of those properties that I need to display is the child page's "mediaArea" (which is the alias). mediaArea contains the image(s) that I am trying to display on the parent page, but I just don't know how to do it using .net user controls. The current code that I am trying to use to display the images looks like this: sw.WriteLine(string.Format(@"<img src=""{0}"" />", child.GetProperty("mediaArea").Value));, where sw is my StringWriter. Anyone have any suggestions?
Thanks!
- Dom
is working on a reply...