Copied to clipboard

Flag this post as spam?

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


  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 08:07
    Christina
    0

    Multinodetreepicker get Id insted of image

    Hi Im using a typedMultiNodeTreePicker and I getting nr insted of image Can someone help me Many thanks /Christina

    <div class="content treeBoxes">
    <div class="columns">
        @{
            var typedMultiNodeTreePicker = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("startboxes");
    
            foreach (var item in typedMultiNodeTreePicker)
            {
    
                 <div class="column">
                    <figure>
                        <div>
                            <a href="@item.Url">
    
                                    <img data-src=" @item.GetPropertyValue("Puffimage")" />}
                            </a>
                        </div>
                        <figcaption>
                            <h3>
                                <a href="@item.Url" style="">@item.Name</a>
                            </h3>
                            <span>
                                <p>
                                    @item.GetPropertyValue("Puffingress")
                                </p>
                            </span>
                            <a class="button is-small is-white is-pulled-right readmore" href="@item.Url">Läs mer</a>
                        </figcaption>
                    </figure>
                </div>
            }
        }
    </div>
    

  • Frans de Jong 522 posts 1762 karma points c-trib
    May 18, 2018 @ 09:05
    Frans de Jong
    0

    I would change the code like this:

    <a href="@item.Url">
        @if(item.HasProperty("Puffimage") && item.HasValue("Puffimage"))
        {
            var image = Umbraco.TypedMedia(item.GetPropertyValue("Puffimage")
            <img data-src="@image.Url" />
        }
        else
        {
           <img src="falbackimage" />
        }
    </a>
    
  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 09:27
    Christina
    0

    Thanks I get null exception and that is strange /Christina

  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 09:47
    Christina
    0

    The firts image i get a number and the others i get Umbraco.Core.Udi[] /Christina

  • Frans de Jong 522 posts 1762 karma points c-trib
    May 18, 2018 @ 09:49
    Frans de Jong
    0

    You can go from a Udi to IpublishedContent with: Udi.Parse("udi").ToPublishedContent()

  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 12:27
    Christina
    0

    Thanks can you help me with the syntax... I tried this but getting error in VS

     var image = Umbraco.TypedMedia(item.GetPropertyValue("Puffimage"));
     var imageurl = Udi.Parse("image").ToPublishedContent(); it doesnt like image as a string
    

    /Christina

  • Frans de Jong 522 posts 1762 karma points c-trib
    May 18, 2018 @ 12:32
    Frans de Jong
    0

    item.GetPropertyValue("puffimage") returns a Udi right? If so this should work:

    IPublishedContent image = Udi.Parse(item.GetPropertyValue("puffimage")).ToPublishedContent();
    string imageUrl = image.Url;
    

    I'm not used to using Umbraco without modelsbuilder so if this doesn't work I need to make some sort of test.

  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 12:50
    Christina
    0

    Many Thanks for trying to help me I got error -cannot convert to a string.

    item.GetPropertyValue("puffimage") 
    

    I want to use modelsbuilder but I only getting error. I dont understand the concept its working on the template but if i want to use something in a view.

    /Christina

  • Frans de Jong 522 posts 1762 karma points c-trib
    May 18, 2018 @ 12:58
    Frans de Jong
    0

    This is a good startingpoint for Modelsbuilder: https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/

  • Frans de Jong 522 posts 1762 karma points c-trib
    May 18, 2018 @ 12:59
    Frans de Jong
    0

    What happens if you do:

    IPublishedContent image = Udi.Parse(item.GetPropertyValue<string>("puffimage")).ToPublishedContent();
    
  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 13:05
    Christina
    0

    Thanks for helping me

    It complains over the last .ToPublishedContent(); udi doesn't contain a definitaion for ToPublishedContent and no extension method to ToPublishedContent accemps a first argument of type udi are you missing an assembly. /Christina

  • Frans de Jong 522 posts 1762 karma points c-trib
    May 18, 2018 @ 13:07
    Frans de Jong
    0

    I'm sorry, I don't have any solution. As I said I always use modelsbuilder. Makes life a lot easier.

  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 13:21
    Christina
    0

    Thanks if i have used modelsbuilder can you give me an example it would help me a lot.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Home>
    

    @using ContentModels = Umbraco.Web.PublishedContentModels; var typedMultiNodeTreePicker = Model.Content.Startboxes;

            foreach (var item in typedMultiNodeTreePicker)
    

    how to i get the puffimage? /Christina

  • Frans de Jong 522 posts 1762 karma points c-trib
    May 18, 2018 @ 13:29
    Frans de Jong
    100
    <div class="columns">
        @{
           IEnumerable<StartBox> typedMultiNodeTreePicker = Model.Content.StartBoxes.Select(x=>new StartBox(x));
    
            foreach (StartBox item in typedMultiNodeTreePicker)
            {
               <div class="column">
                  <figure>
                     <div>
                        <a href="@item.Url">
                           @if(item.Puffimage != null)
                           {
                              <img data-src="@item.Puffimage.Url" />
                           }
                           else
                           {
                              <img src="falbackimage" />
                           } 
                        </a>
                     </div>
                 <figcaption>
                    <h3>
                       <a href="@item.Url" style="">@item.Name</a>
                    </h3>
                    <span>
                        <p>
                           @item.Puffingress
                        </p>
                     </span>
                  <a class="button is-small is-white is-pulled-right readmore" href="@item.Url">Läs mer</a>
               </figcaption>
             </figure>
          </div>
       }
    

    }

  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 13:49
    Christina
    0

    Big Big Thanks for helping me out i'm so happy it works/Christina

  • Bent Holz 94 posts 257 karma points
    May 18, 2018 @ 09:10
    Bent Holz
    0

    Don't know if this does the trick:

    <img data-src=" @item.GetPropertyValue("Puffimage").Url" />
    

    /Bent

  • Christina 111 posts 344 karma points notactivated
    May 18, 2018 @ 09:33
    Christina
    0

    Thanks i tried that but it doesnt work /Christina

  • 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