Copied to clipboard

Flag this post as spam?

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


  • J 447 posts 864 karma points
    Mar 17, 2016 @ 18:54
    J
    0

    CSHTML looping through folder

    I am trying to loop through one folder and get the value from a property contained within the fields on a particular document type in a CSHTML file using Umbraco 6. So i used the default code and added a single line which throws an error:

    @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
    @if (Model.Children.Where("Visible").Any())
    {
        @* Get the first page in the children, where the property umbracoNaviHide is not True *@
        var naviLevel = Model.Children.Where("Visible").First().Level;
    
        @* Add in level for a CSS hook *@
        <ul class="level-@naviLevel">            
            @* For each child page under the root node, where the property umbracoNaviHide is not True *@
            @foreach (var childPage in Model.Children.Where("Visible"))
            {
                <li>
                    @{var img = Umbraco.TypedMedia(childPage.GetPropertyValue("imgName"));}
                    <a href="@childPage.Url">@childPage.Name + img</a>
    
                    @* if the current page has any children, where the property umbracoNaviHide is not True *@
                    @if (childPage.Children.Where("Visible").Any())
                    {
                        @* Call our helper to display the children *@
                        @childPages(childPage.Children )
                    }
                </li>
            }
        </ul>
    }
    

    The error returned at first is The type or namespace name 'TypedMedia' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)

    So i add @inherits umbraco.library at the top of the file and i get the error "no suitable method found to override". Could anyone advise how i am supposed to do this?

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Mar 18, 2016 @ 11:05
  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Mar 20, 2016 @ 20:12
    Dennis Adolfi
    0

    Did it work out for you? Did you find a answer to your problem on the documentation page? Let me know if i can be of any help.

  • J 447 posts 864 karma points
    Mar 22, 2016 @ 16:11
    J
    1

    I found an example on the internet and used that instead

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies