Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've tried following the code snippet here https://gist.github.com/1170848 but can't seem to get it working.
My xml is like this:
<FancyDressProduct id="1819" parentID="1742" level="5" writerID="0" creatorID="0" nodeType="1240" template="1057" sortOrder="1" createDate="2012-02-23T15:48:35" updateDate="2012-03-02T08:33:25" nodeName="Santa" urlName="santa" writerName="Ian Houghton" creatorName="Ian Houghton" path="-1,1073,1153,1178,1742,1819" isDoc=""> <productTitle>Santa</productTitle> <crops> <crops date="02/03/2012 08:33:16"> <crop name="fancyDress" x="0" y="0" x2="400" y2="600" url="/media/21002/278_fancyDress.jpg" /> </crops> </crops> <productDetails><![CDATA[ <p><span>Large; Cotton santa jacket with white fur trim and trousers. Boot covers, wig 'n' beard, hat and gloves all included.</span></p> ]]></productDetails> <productCode>C-01</productCode> <reservePrice>25</reservePrice> <deposit>25</deposit> <productSize>Large</productSize> <featuredProduct>0</featuredProduct> <umbracoFile>/media/21002/278.jpg</umbracoFile> <metaTitle><![CDATA[]]></metaTitle> <metaDescription><![CDATA[]]></metaDescription> <metaKeywords><![CDATA[]]></metaKeywords> <umbracoUrlName /> <umbracoUrlAlias /> <umbracoRedirect /> <umbracoNaviHide>0</umbracoNaviHide> </FancyDressProduct>
and my razor code is:
@inherits umbraco.MacroEngines.DynamicNodeContext @{ var pagesToList = @Model.Children; // configuration var itemsPerPage = String.IsNullOrEmpty(Parameter.ItemsPerPage) ? 3 : int.Parse(Parameter.ItemsPerPage); var previousLabel = String.IsNullOrEmpty(Parameter.PreviousLabel) ? "Previous" : Parameter.PreviousLabel; var nextLabel = String.IsNullOrEmpty(Parameter.NextLabel) ? "Next" : Parameter.NextLabel; // paging calculations var numberOfItems = pagesToList.Count(); int currentPage = 1; if (!int.TryParse(HttpContext.Current.Request.QueryString["Page"], out currentPage)) { currentPage = 1; } currentPage--; var numberOfPages = numberOfItems % itemsPerPage == 0 ? Math.Ceiling((decimal)(numberOfItems / itemsPerPage)) : Math.Ceiling((decimal)(numberOfItems / itemsPerPage))+1; <p> Total Items: @numberOfItems <br /> Items per Page: @itemsPerPage<br /> Pages: @numberOfPages;<br /> Current Page: @(currentPage) </p> // Products List <ul class="productsLandscape"> @foreach(var item in pagesToList.Skip(currentPage*itemsPerPage).Take(itemsPerPage)) { <li> <a id="fancyDress" href="@item.umbracoFile"> <img src="@item.crops.Find("@name","fancyDress").url" alt="" /> </a> <div class="fancyDressDetails left"> <h3>@item.Name</h3> <p>@item.productDetails</p> <br/> <br/> <p>Reserve price: <b>£@item.reservePrice</b> (+ £20.00 deposit)</p> <p>Product code: <b>@item.productCode</b> (please quote in correspondence)</p> <p>Size: <b>@item.productSize</b></p> <input type="button" text="Reserve Item" /> </div> <div class="clear"></div> <div class="divider"></div> </li> } </ul> <p class="pagingPages"> @{ // Google style paging links if (currentPage > 0) { <a href="?page=@(currentPage)">« @previousLabel</a> } else { <span class="pagingDisabled">« @previousLabel</span> } var Pages = Enumerable.Range(1, (int)numberOfPages); foreach(var number in Pages) { if (number-1 != currentPage) { <a href="?page=@number">@number</a> } else { @number } @Html.Raw("  "); } if (currentPage < Pages.Count()-1) { <a href="?page=@(currentPage+2)">@nextLabel »</a> } else { <span class="pagingDisabled">@nextLabel »</span> } } </p> }
but I'm getting this error:
Error loading Razor Script FancyDressListing.cshtml'string' does not contain a definition for 'Find'
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Image crop in Razor
I've tried following the code snippet here https://gist.github.com/1170848 but can't seem to get it working.
My xml is like this:
and my razor code is:
but I'm getting this error:
Error loading Razor Script FancyDressListing.cshtml
'string' does not contain a definition for 'Find'
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.