Copied to clipboard

Flag this post as spam?

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


  • hetaurhet 245 posts 267 karma points
    Mar 04, 2012 @ 17:28
    hetaurhet
    0

    uBlogsyListPostsHome.cshtml with thumb image

    hello

    I want latest posts with thumb images to be shown.. I inserted property of type media picker for the same so that user can select thumb image with each post.

    in Razor to access image I use following line.. but it is throwing error

    Error loading MacroEngine script (file: /uBlogsy/uBlogsyListPostsHome.cshtml)

    ..........

    @foreach (DynamicNode n in nodes)
                    {
                        dynamic link = Library.MediaById(n.postThumbImage);
                        <div class="updates-item">
                            <a href="@n.Url" title="@n.GetProperty("uBlogsyContentTitle").Value" target="_blank" >
                                <img src="@link.umbracoFile" width="60" height="43" border="0" class="updates-img"/>
                            </a>
                            <a href="@n.Url" title="@n.GetProperty("uBlogsyContentTitle").Value" class="updates-text" target="_blank">
                 ...

                .....

                   }

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 13, 2012 @ 00:18
    Anthony Dang
    0

    It's probably because n is a properly instantiated DynamicNode, not of type dynamic

    Try changing this

    dynamic link = Library.MediaById(n.postThumbImage); 

    to this:

    dynamic link = Library.MediaById(n.GetPropertyValye("postThumbImage")); 


  • hetaurhet 245 posts 267 karma points
    Mar 17, 2012 @ 06:14
    hetaurhet
    1

    with the DynamicNode type ... I could solved the problem by using following line..

    dynamic mediaItem = @n.Media("postThumbImage");

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Mar 17, 2012 @ 15:18
    Anthony Dang
    0

    Nice.

    Yeah that's a neater solution.

     

Please Sign in or register to post replies

Write your reply to:

Draft