Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 364 posts 918 karma points
    Mar 23, 2015 @ 18:13
    Craig O'Mahony
    0

    Get Media Items

    Hi all,

    I've a got a clean umbraco install v7.2.4 and I've created a new media type of Slider Folder and Slider Items so in the media section I've created the folder (Node 1051) and some Slider Items underneath it.

    And in razor (developer section - Partial View Macro Files) I'm trying to loop through the slider items and put some output onto my page but no matter what I attempt the page just gives me the error of Error loading Partial View script (file: ~/Views/MacroPartials/Show Slider Graphics.cshtml)

    My script looks like this (obviously you can see how far I've got!)

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @{var node = Model.GetNodeById(1051);}

    This is my first real venture in MVC/Razor and I'm stumped at the first!

    Any help would be marvellous.

    Craig

  • Nicholas Westby 2054 posts 7100 karma points c-trib
    Mar 23, 2015 @ 18:18
    Nicholas Westby
    100

    You want Umbraco.TypedMedia(1051). From there, you can loop over the children.

    To get more info on the error, modify your config/umbracoSettings.config file so you see macro errors:

    <MacroErrors>throw</MacroErrors>
    

    You can also look for errors in App_Data/Logs/UmbracoTraceLog.txt.

  • Craig O'Mahony 364 posts 918 karma points
    Mar 23, 2015 @ 18:22
    Craig O'Mahony
    0

    You may friend are an international superstar!

    That has driven me mental!

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 23, 2015 @ 18:23
    Dennis Aaen
    0

    Hi Craig,

    You can do it like this,

    @{ 
        var node = Umbraco.Media(1051);
    }

    See the documentation here: https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/

    Hope this helps,

    /Dennis

  • Craig O'Mahony 364 posts 918 karma points
    Mar 23, 2015 @ 18:24
    Craig O'Mahony
    0

    Cheers Dennis,

    I'll have a butchers at that.

    Thanks matey.

Please Sign in or register to post replies

Write your reply to:

Draft