Copied to clipboard

Flag this post as spam?

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


  • Robert 5 posts 55 karma points
    May 05, 2014 @ 02:06
    Robert
    0

    Error loading partial view script

    I created a partial view macro... I am trying to get pictures from a media folder and loop through them to add to felx slider.... a complete copy almost of the gallery example.

     

    Here is the code

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
     @{
      
      
     if (Modal.HasValue("SlidePhotos"))
     {
      var MediaFolder = Library.MediaById(Modal.SlidePhotos);
      
     <div class="flexslider">
                            <ul class="slides">
           @foreach (var photo in MediaFolder.childen)
           {
                                 <li>
                                    <img class="SlideImage" src="@photo.umbracoFile" />
                                </li>
             }
             
                            </ul>
          </div>
           
     }
     }

     

    The page that is calling tthe macro has a media picker called SlidePhotos.  I am not sure what I have done wrong? 

     

    Thank you in advance

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 05, 2014 @ 08:11
    Dennis Aaen
    1

    Hi Robert,

    You have used the old legacy razor. When you´re using MVC the currentpage is not represented by Model. but by CurrentPage.

    Try something like this instead.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
        @{
            if (CurrentPage.HasValue("SlidePhotos")){
           
            var MediaFolder = Umbraco.Media(CurrentPage.SlidePhotos);
     
            <div class="flexslider">
                <ul class="slides">
                    @foreach (var photo in MediaFolder.Childen){
                        <li>
                            <img class="SlideImage" src="@photo.umbracoFile" alt="@photo.Name" />
                        </li>
                     }
                     
                </ul>
                  </div>
                  
             }
     }

    You can find the documentation for the media picker here: http://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors/Media-Picker and if you are using version 7 the documentation is here: http://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/Built-in-Property-Editors-v7/Media-Picker

    Hope this helps,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft