Copied to clipboard

Flag this post as spam?

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


  • Robin Hansen 135 posts 368 karma points
    Jun 13, 2012 @ 12:28
    Robin Hansen
    0

    Full image path from uComponents UcMultiNodeTreePicker

    I'm trying so hard to extract the image path fron the first img. selected in UcMultiNodeTreePicker - with no further luck:


     

    However I've a working example in xlst - but I have'nt managed to convert it to Razor - anyone know how...? 

    umbraco.library:GetMedia(umbraco.library:GetXmlNodeById(.)/pageImage/MultiNodePicker/nodeId[1]0)
  • Robin Hansen 135 posts 368 karma points
    Jun 13, 2012 @ 13:24
    Robin Hansen
    0

    Maybe I should mention that I need to have the img path in this foreach loop:

    @{
       var newsAreaNode = Model.SideNormals.First();
    }
    @{
    foreach (var item in newsAreaNode.Descendants().Where("NodetypeAlias == \"Artikel\""))
    {
    @*imgpath here*@
    }
    }

  • Kasper Dyrvig 246 posts 379 karma points
    Jun 13, 2012 @ 13:37
    Kasper Dyrvig
    0

    Hi Robin

    I have had my struggle with the multi-node tree picker too. I needed it for content nodes. Here is my code, modified based on your inputs... (this code is for the multi-node tree picker's data saved as csv (not xml)) 

    @{
    string[] imagesString = Model.MiltiNodeTreePickerPropertyTypeAliasHere.Split(',');
    List images = new List();
    }
    @foreach(string i in imagesString)
    {
    if (!images.Contains(i))
    {
    images.Add(i);
    }
    }
    @foreach(var item in images)
    {
    var image = Library.MediaById(item);
    <img src="@image.umbracoFile" alt="@image.Name"/>

    PS: Not tested...

  • Robin Hansen 135 posts 368 karma points
    Jun 13, 2012 @ 14:02
    Robin Hansen
    0

    Thank you Kasper - this looks promissing, however the img path NEEDs to be in this foreach loop:

    foreach (var item in newsAreaNode.Descendants().Where("NodetypeAlias == \"Artikel\""))
    {

    @*imgpath here*@

    }

    Can I squize your example with all loops inside that...?

  • Kasper Dyrvig 246 posts 379 karma points
    Jun 13, 2012 @ 14:20
    Kasper Dyrvig
    0

    I think I need more information about your structure to help more. But the @image.umbracoFile is the image's path. 

  • Robin Hansen 135 posts 368 karma points
    Jun 13, 2012 @ 14:42
    Robin Hansen
    0

    Thats fair enough - I've a standard Umbraco Rss page (Customized to read only certain doc types) - by which I reads some info from - in that case I need to read an image path:

    @{

    //Change mime type
    umbraco.library.ChangeContentType("text/xml");   

    //Get the domain 
    var siteURL = "http://" + Request.Url.Host;

    //Get the news area node (only one of these per site)
    var newsAreaNode = Model.SideNormals.First();

    //Get the latest createDate of all news items to use as the RSS feed updateDate
    var RSSFeedPubDate = newsAreaNode.Children.Where("articleDate <= DateTime.Now && Visible && umbracoNaviHide != true").OrderBy("UpdateDate desc").First();

    }

    <?xml version="1.0" encoding="UTF-8"?>

    <rss version="2.0" 

        xmlns:content="http://purl.org/rss/1.0/modules/content/" 

        xmlns:wfw="http://wellformedweb.org/CommentAPI/" 

        xmlns:dc="http://purl.org/dc/elements/1.1/" 

        xmlns:rssdatehelper="urn:rssdatehelper">

            <channel>

                <title>ANR News Feeds</title>

                <link>@siteURL</link>

                <pubDate>@RSSFeedPubDate.UpdateDate.ToString("r")</pubDate>

                <generator>umbraco</generator>

                <description>Add your description here</description>

                <language>en</language>

                @{

                    foreach (var item in newsAreaNode.Descendants().Where("NodetypeAlias == \"Artikel\""))

                    {

     

                     <item>  

                            <img> @*ImagePath Here*@</img>

                            <title>@item.Name</title>

                            <link>@item.Url</link>

                            <pubDate>@item.UpdateDate.ToString("r")</pubDate>

                            <guid>@item.Url</guid>

                            <content:encoded><![CDATA[@item.bodyText]]></content:encoded>           

                        </item>

                    }

                }

            </channel>

    </rss>

     

  • Robin Hansen 135 posts 368 karma points
    Jun 13, 2012 @ 15:05
    Robin Hansen
    0

    I now managed to solve the issue by this foreach loop:

     

    foreach (var item in newsAreaNode.Descendants().Where("NodetypeAlias == \"Artikel\""))
    {
    @foreach (var nodeId in item.pageImage)
    {
    var contentItem = item.NodeById(nodeId.InnerText);
    <img>@contentItem.Url</img>
    }
    }

    But thank you very much for your help... :-)

     

  • Kasper Dyrvig 246 posts 379 karma points
    Jun 13, 2012 @ 15:07
    Kasper Dyrvig
    0

    Okay. I think you may need to hardcode the root, then you can add the image path. Here is some new code:

    @{
     var root = "http://www.domain.com";
     foreach (var item in newsAreaNode.Descendants().Where("NodetypeAlias == \"Artikel\""))
     {
      if(item.HasValue("MiltiNodeTreePickerPropertyTypeAliasHere"))
      {
       string[] imagesString = item.MiltiNodeTreePickerPropertyTypeAliasHere.Split(',');
       List images = new List();
       foreach(string i in imagesString)
       {
        if (!images.Contains(i))
    {
    images.Add(i);
    }
       }
       var image = Library.MediaById(images.First());
       var output = root + image;
      }
      <item>
       <img>@output</img>
       <title>@item.Name</title>
       <link>@item.Url</link>
       <pubDate>@item.UpdateDate.ToString("r")</pubDate>
       <guid>@item.Url</guid>
       <content:encoded><![CDATA[@item.bodyText]]></content:encoded>
      </item>
     }
    }
  • Kasper Dyrvig 246 posts 379 karma points
    Jun 13, 2012 @ 15:09
    Kasper Dyrvig
    0

    Ha! We added answer at the same time :-)

    Good you found a solution.

Please Sign in or register to post replies

Write your reply to:

Draft