Copied to clipboard

Flag this post as spam?

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


  • Jeppe Ladefoged 15 posts 65 karma points
    Oct 02, 2014 @ 08:04
    Jeppe Ladefoged
    0

    Recursive Umbraco.TypedMedia

    I'm trying to figure out how i can make the below code recursive throughout my site. I have 3 div's with different image icons defined on the frontpage (home) and need these three on all pages.

    Did a lot of searching and i'm not quite sure what's going on. To my eyes i should work.

    Currently i have tried ("serviceOneIcon" , recursive: true), ("serviceOneIcon", true) and also using underscore eg. (_serviceOneIcon).

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

    Thanks for your help in advance

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 02, 2014 @ 08:14
    Dennis Aaen
    0

    Hi Jeppe,

    Did you try something like this or where did you place the true in your code.:

    <div class="icon">
        @{if(Model.Content.HasValue("serviceOneIcon",true)){
            var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue("serviceOneIcon"));
            <img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")"/>
        }}
    </div>

    Hope this helps,

    /Dennis

  • Jeppe Ladefoged 15 posts 65 karma points
    Oct 02, 2014 @ 08:25
    Jeppe Ladefoged
    0

    Hi Dennis

    Thanks for your suggestion. I pasted in your code and get a server error on subpages "The value of parameter 'id' must be either a string or an integer". The frontpage still works though.

    Frontpage: http://nssas.dk.nt7.unoeuro-server.com/

    Subpage: http://nssas.dk.nt7.unoeuro-server.com/produkter.aspx

    Thanks again

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 02, 2014 @ 08:29
    Dennis Aaen
    0

    Hi Jeppe,

    What if you do something like this:

    <div class="icon">
        @{if(Model.Content.HasValue("serviceOneIcon",true)){
            var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("serviceOneIcon"));
            <img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")"/>
        }}
    </div>

    Hope this helps,

    /Dennis

  • Jeppe Ladefoged 15 posts 65 karma points
    Oct 02, 2014 @ 08:33
    Jeppe Ladefoged
    0

    Thanks for your suggestion. Unfortunately results in a server error also "Object reference not set to an instance of an object."

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 02, 2014 @ 08:37
    Dennis Aaen
    0

    Hi Jeppe,

    Okay hmm what about this:

    <div class="icon">
        @{if(Model.Content.HasValue("serviceOneIcon",true)){
            var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue<int>("serviceOneIcon", true));
            <img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")"/>
        }}
    </div>

    Hope this helps,

    /Dennis

  • Jeppe Ladefoged 15 posts 65 karma points
    Oct 02, 2014 @ 08:45
    Jeppe Ladefoged
    0

    No error on either pages but also no icon images output in frontend... I'm really confused, all of your code should work

    I'm new to installaing Umbraco on the server however. Could it be my installation i messed up? I deployed/published a completely clean Umbraco 6.2.2 via Webdeploy and using the simple database (not SQL) setup option.

    Thanks so much for all your help :)

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Oct 02, 2014 @ 10:29
    Andy Butland
    0

    Maybe off base but if you've been working on a local installation and have deployed to a remote server, are you maybe just missing the media files?  In other words the reference to them is in the database, but when you use Web Deploy you aren't copying over the physical files themselves.  That would be possible as Web Deploy only picks up the files referenced in the VS.Net project file.  If so probably you'll need to copy them up manually.

    Andy

  • Jeppe Ladefoged 15 posts 65 karma points
    Oct 02, 2014 @ 12:33
    Jeppe Ladefoged
    0

    Hi Andy

    Thanks for your suggestion. I started with a clean install on the remote dev server so media files were uploaded and selected directly via Umbraco backoffice on the server.

    Any other suggestions will be greatly appreciated.

    Thanks again

Please Sign in or register to post replies

Write your reply to:

Draft