go to the root and check all nodes with Alias PortfolioItem i have multiple of these.
Next step-> Loop over the property portfolioImages (DAMP) and get all the mediaItems from those
Next step->my logic is to put all the mediaItem nodes in a DynamicNodeList and use the .Take(10).OrderBy("someDate desc") for a slideshow on a homepage with recent artworks.
I hope somebody has a solution or first steps to go on with the problem.
Do you want 10 nodes from the first PortfolioItem and then 10 from the next PortfolioItem ?
Or do you want just 10 portfolioImages from your entire site?
If it is the latter that you want then you can do this....
@using umbracoMacroEngines; @using System.Linq @{ var dampXml =newDynamicNode(-1).Descendants("portfolioImages").Items.OrderByDescending(x => x.GetProperty("yourDatePropertyAlias").Value).Take(10); foreach(var xml in dampXml){ // get the umbracoFile value from the DAMP xml string url = XDocument.Parse(xml).Descendants("umbracoFile").FirstOrDefault();
Error loading Razor Script ~/macroscripts/startseiteportfolio.cshtml c:\inetpub\wwwroot\3dHTML5\macroScripts\StartseitePortfolio.cshtml(9): error CS1502: The best overloaded method match for 'System.Xml.Linq.XDocument.Parse(string)' has some invalid arguments
i referrenced @using System.Linq and @using System.Xml.Linq and @using System.Xml :/
foreach(var xml indampXml){ // get the umbracoFile value from the DAMP xml string url =XDocument.Parse(xml).Descendants("umbracoFile").FirstOrDefault();
Help needed - Tricky Data and get them - different methods failed -
Okay here's my Problem. I have 2 Documenttypes Portfolio and Portfolioitem.
in Portfolioitem i have DAMP with multiple stored Images. The Property is portfolioImages.
Okay i've started out with the following:
Everything works fine, but i have the problem that i can't use the .Take(10) or something else.
Somebody have an idea how to do the trick better than that.
Thanks for every usefull tip.
You can't use .Take or .Skip on DynamicXml. You could use LinqToXml instead to do this.
Jeroen
There is a problem with extension methods on dynamic objects.
If you instantiate a DynamicNode, then call those methods on it, you will have access to Take()
eg.
This is my XML and now i will do the following:
go to the root and check all nodes with Alias PortfolioItem i have multiple of these.
Next step-> Loop over the property portfolioImages (DAMP) and get all the mediaItems from those
Next step->my logic is to put all the mediaItem nodes in a DynamicNodeList and use the .Take(10).OrderBy("someDate desc") for a slideshow on a homepage with recent artworks.
I hope somebody has a solution or first steps to go on with the problem.
Thanks to all hints. Greetings Toni
<PortfolioItem id="1171" parentID="1072" level="3" writerID="0" creatorID="0" nodeType="1061" template="0" sortOrder="6" createDate="2011-08-05T12:59:58" updateDate="2011-08-05T16:21:10" nodeName="3d" urlName="3d" writerName="Toni Becker" creatorName="Toni Becker" path="-1,1069,1072,1171" isDoc="">
<portfolioImages>
<DAMP fullMedia="">
<mediaItem>
<Image id="1161" version="16ac3c18-8af7-4c09-9c95-249dd48c32ba" parentID="1121" level="4" writerID="0" nodeType="1032" template="0" sortOrder="3" createDate="2011-08-05T12:50:49" updateDate="2011-08-05T12:50:49" nodeName="3d3.jpg" urlName="3d3.jpg" writerName="Toni Becker" nodeTypeAlias="Image" path="-1,1046,1049,1121,1161">
<umbracoFile>/media/1161/3d3.jpg</umbracoFile>
<umbracoWidth>1024</umbracoWidth>
<umbracoHeight>768</umbracoHeight>
<umbracoBytes>248974</umbracoBytes>
<umbracoExtension>jpg</umbracoExtension>
<captionText />
<captionText2 />
<portfolioThumbs>
<crops date="05/08/2011 12:50:50">
<crop name="Slideshow Groß" x="0" y="101" x2="1024" y2="666" url="/media/1161/3d3_Slideshow Groß.jpg" />
<crop name="Slideshow Klein" x="0" y="111" x2="1024" y2="656" url="/media/1161/3d3_Slideshow Klein.jpg" />
<crop name="Slider Porfolio" x="11" y="0" x2="1011" y2="768" url="/media/1161/3d3_Slider Porfolio.jpg" />
<crop name="Unternehmen Slider" x="0" y="48" x2="1024" y2="718" url="/media/1161/3d3_Unternehmen Slider.jpg" />
<crop name="Leistung" x="128" y="0" x2="896" y2="768" url="/media/1161/3d3_Leistung.jpg" />
<crop name="Portfolio" x="0" y="88" x2="1024" y2="678" url="/media/1161/3d3_Portfolio.jpg" />
<crop name="Blog" x="0" y="251" x2="1024" y2="515" url="/media/1161/3d3_Blog.jpg" />
<crop name="Sidebar" x="0" y="33" x2="1024" y2="733" url="/media/1161/3d3_Sidebar.jpg" />
</crops>
</portfolioThumbs>
<portfolioVideoLink />
<portfolioTitel />
<portfolioText><![CDATA[]]></portfolioText>
</Image>
</mediaItem>
<mediaItem>
<Image>
<umbracoFile></umbracoFile>
<portfolioThumbs>
.....
</portfolioThumbs>
</Image>
</mediaItem>
<mediaItem>
<Image>
<umbracoFile></umbracoFile>
<portfolioThumbs>
.....
</portfolioThumbs>
</Image>
</mediaItem>
</DAMP>
</portfolioImages>
</PortfolioItem>
Do you want 10 nodes from the first PortfolioItem and then 10 from the next PortfolioItem ?
Or do you want just 10 portfolioImages from your entire site?
If it is the latter that you want then you can do this....
Throws an error:
Error loading Razor Script ~/macroscripts/startseiteportfolio.cshtml
c:\inetpub\wwwroot\3dHTML5\macroScripts\StartseitePortfolio.cshtml(9): error CS1502: The best overloaded method match for 'System.Xml.Linq.XDocument.Parse(string)' has some invalid arguments
i referrenced @using System.Linq and @using System.Xml.Linq and @using System.Xml :/
My bad...
I think this will work...
dampXml was meant to be an IEnumberable<string>
hmm same problem appearing :;/
is working on a reply...