Copied to clipboard

Flag this post as spam?

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


  • mikkel 143 posts 365 karma points
    Dec 18, 2016 @ 15:37
    mikkel
    0

    keep getting renderbody error

    Hello I keep getting this error with @RenderBody (). I have made a master document type and below it a home page document type. When I use @RenderBody on MasterTemplaten then comes the error, what is it that i dont do right??

    and merry christmas to every one :)

  • Georgs Bormanis 25 posts 122 karma points admin hq c-trib
    Dec 19, 2016 @ 14:25
    Georgs Bormanis
    0

    Hey there Mikkel! Would you mind snapping a screenshot for me so I could take look of the error and your code? :)

    Cheers,

    -Georgs

  • mikkel 143 posts 365 karma points
    Dec 23, 2016 @ 14:49
    mikkel
    0

    Excuse my late reply, I've been a little hung up.I had solved it, I should put a comma and remove the semicolon and so it worked.I have another problem, mediapicker how do I get it to display the picture out of the page where the image to be displayed, and what do you use to choose only one image, if there are only have to be 1 photo on the page.

    I've tried different things to get the picture shown as, for example

    @if (CurrentPage.HasValue("vaelgBillede")) { var caseStudyImagesList = CurrentPage.CaseStudyImages.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); var caseStudyImagesCollection = Umbraco.Media(caseStudyImagesList);

    @if (CurrentPage.HasValue("vaelgBillede"))
            {
                var caseStudyImagesList = CurrentPage.CaseStudyImages.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                var caseStudyImagesCollection = Umbraco.Media(caseStudyImagesList);
    
                foreach (var caseStudyImage in caseStudyImagesCollection)
                {
                    <img src="~/media/@caseStudyImage.Url" style="width:300px;height:300px" />
                }
            }
    

    And

     <img src="~/Media/1002/@Umbraco.Field("vaelgBillede")" />
    

    and

    @Umbraco.Field("vaelgBillede")

    and

    <img src="~/Media/1002/' + @Umbraco.Field("vaelgBillede") + '" />
    

    and the last one

    <img src="../Media/1002/' + @Umbraco.Field("vaelgBillede") + '" />
    

    i am a litle lost on that one

    thanks for loocking at it and merry christmas :D

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 23, 2016 @ 15:53
    Dennis Aaen
    100

    Hi Mikkel,

    If you only want to pick one image, then you should you the media picker as you do and then use this Razor code.

    @{      
        if (CurrentPage.HasValue("vaelgBillede")){                                         
            var dynamicMediaItem = Umbraco.Media(CurrentPage.vaelgBillede);
            <img src="@dynamicMediaItem.umbracoFile" alt="@dynamicMediaItem.Name"/>
        }
    }
    

    The above code is dynamic Razor if you want to use strongly typed Razor then the code needs to look like this.

    @{
        if(Model.Content.HasValue("vaelgBillede")){
            var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue("vaelgBillede")); 
            <img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")"/>    
        }   
    }
    

    Hope this helps,

    /Dennis

  • mikkel 143 posts 365 karma points
    Dec 27, 2016 @ 10:31
    mikkel
    0

    that workt great, thanks for your help :)

Please Sign in or register to post replies

Write your reply to:

Draft