Copied to clipboard

Flag this post as spam?

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


  • NiQ 24 posts 45 karma points
    Oct 24, 2011 @ 13:32
    NiQ
    0

    Embedded Content in codebehind, get all properties?

     

    Im using currentNode.GetProperty().Value to get the value from my Embedded Content but how do I get all the properties?

    I have "image", "text" and "link" set but I don't have a clue how to loop through all the images and print out the properties...

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 24, 2011 @ 14:45
    Dirk De Grave
    0

    Hi NiQ, you'll have to find out how the info is stored in the cached xml. Open up the /App_Data/umbraco.config file and search for your document (and property of type embedded content). Most probably it's stored as xml, so you use

    var document = XDocument.Parse(currentNode.GetProperty("alias").Value.ToString());

    and use linq 2 xml to query the data stored.

     

    Cheers,

    /Dirk

  • NiQ 24 posts 45 karma points
    Oct 24, 2011 @ 15:26
    NiQ
    0

    Yeah that worked. I now get both the image, text and link of all three images I have embedded in the property but they all are merged into one string.

    In Umbraco I have three images attached to this property, are there anyway I can split this variable so I can make a loop?

    It would be great if I could do a foreach loop with the images that are assigned to this property.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 24, 2011 @ 15:50
    Dirk De Grave
    0

    Can you show what you get as xml?

     

    Cheers,

    /Dirk

  • NiQ 24 posts 45 karma points
    Oct 24, 2011 @ 17:06
    NiQ
    0

    <data>
    <floatimages>
    <item id="1">
    <text propertyid="3">Food</text>
    <image propertyid="1">1175</image>
    <url propertyid="2">1173</url>
    </item>
    <item id="2">
    <text propertyid="3">Image2</text>
    <image propertyid="1">1176</image>
    <url propertyid="2" />
    </item>
    <item id="3">
    <text propertyid="3">Image3</text>
    <image propertyid="1">1177</image>
    <url propertyid="2" />
    </item>
    </data>
    </floatimages> 

    There.

    It would also be great if someone could help me with geting the URL of the imagename. I manage to get the imagename in a variable but what I need is the images url. :)

     

  • NiQ 24 posts 45 karma points
    Oct 25, 2011 @ 08:54
    NiQ
    0

    I just noticed I only got the "text" property value due to the fact im using this code: 

    foreach (string item in document.Descendants("text"))
    {

    How do I loop them trough to be able to get acces to both "text", "image" and "url"?

    And also, "url" isn't actually the url of the image.. don't really know how to get url.. any help on this would be awesome.

Please Sign in or register to post replies

Write your reply to:

Draft