Copied to clipboard

Flag this post as spam?

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


  • Anthony Candaele 1197 posts 2049 karma points
    Dec 31, 2011 @ 16:47
    Anthony Candaele
    0

    extending uBlogsyPostLists.cshtml with image

    Hi,

    I'm trying to extend the uBlogsyPostLists.cshtml script with an image property (uBlogsyPostImage).

    I'm using DAMP and the normal way of acceccing images uploaded with DAMP is:

    dynamic file Model.uBlogsyPostImage.mediaItem.NewsImage
              
              <img style="float:right;" src="/[email protected]&amp;width=150" class="eventimage" />

    But in the uBlogsyListPosts.cshtml I' don't have acces to .Model because I'm in a loop of DynamicNode:

    @foreach (DynamicNode in nodes)

    {

    ...

    }

    So I try to access an the image property of my post like this

    dynamic file @n.Media("uBlogsyPostImage.mediaItem.NewsImage");

    but this doesn't seem to work.

    Does some has an idea how I can my image property on my uBlogsy post?

    Thanks for your help,

    Anthony

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Dec 31, 2011 @ 21:11
    Sebastiaan Janssen
    0

    Can you change DynamicNode to var and try again?

  • Anthony Candaele 1197 posts 2049 karma points
    Jan 01, 2012 @ 09:58
    Anthony Candaele
    0

    Hi Sebastiaan,

    First of all, I wish you lot's of happiness and a good health for 2012. And may we have lots of exciting times and succes in Umbraco land :)

    Concerning the image, I tried your suggestion and changed DynamicNoe this code:

    <ul class="list-2">
                    @foreach (var in nodes)
                    {
                        dynamic file @n.Media("uBlogsyPostImage.mediaItem.NewsImage");                   
                        <li>
                            <img src="@file" />
                            <strong><span>@n.GetProperty("uBlogsyPostDate").Value.FormatDateTimeOrdinal("d MMMM yyyy")</strong>
                            <href="@n.Url">
                            @n.GetProperty("uBlogsyContentTitle").Value
                            </a>
                           
                        </li>
                    }
                </ul>

    but this just results in an empty tag:

     
      src="" />
      10th januari 2011
      href="/hse-articles/blog/2011/79-of-eu-managers-are-concerned-by-work-related-stress.aspx">
      79% of EU managers are concerned by work-related stress
       
       
     

     


    thanks for your help,

    Anthony

Please Sign in or register to post replies

Write your reply to:

Draft