Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sean Dooley 273 posts 490 karma points
    Jul 29, 2011 @ 15:50
    Sean Dooley
    0

    Iterator GetPreValues

    Currently my code is as follows

    var recipeTypes = umbraco.library.GetPreValues(1174);
    <p>@recipeTypes</p>
    <ul>
    @foreach(var item in recipeTypes) {
    <li>@item</li>
    }
    </ul>

    This returns the following

    MS.Internal.Xml.XPath.XPathSelectionIterator

    • Family FavouritesClassicsSweetsTopping
    How do you iterator umbraco.library.GetPreValues() using Razor into list items?
  • Sean Dooley 273 posts 490 karma points
    Jul 29, 2011 @ 16:09
    Sean Dooley
    0

    I have used the snippet below to achieve what I was looking for

     

    @{

    XPathNodeIterator recipeTypes = umbraco.library.GetPreValues(1174);

    recipeTypes.MoveNext();

    XPathNodeIterator preValueIterator = recipeTypes.Current.SelectChildren("preValue","");

    <li class="heading">Ingredient</li>

    <ul>

    @while(preValueIterator.MoveNext()) {

    searchUrl = String.Format("{0}&mainIngredient={1}", @templateUrl, @preValueIterator.Current.GetAttribute("id",""));

    <li>

    <a href="@searchUrl">

    @preValueIterator.Current.Value

    </a>

    </li>

    }

    </ul>

    }

    Apologies for the code formatting, the creating a post allowed me to set styling to 'Code' but in a reply it has changed to 'Preformatted'... which doesn't work anywhere near as good?!

     

  • 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.

Please Sign in or register to post replies