Copied to clipboard

Flag this post as spam?

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


  • Willem Folscher 3 posts 73 karma points
    Mar 31, 2016 @ 10:51
    Willem Folscher
    0

    Image Slider - Macro

    Hi

    I am new and struggling badly.

    Trying to create a macro in order to pull the images I have selected into my slider.

    Doctypes - Slider with child doctype Slider Image

    Here I am calling the macro :

    <div class="element clearfix col3-3 home auto">
           <div class="flexslider">
        <div class="images">
            <ul class="slides">
                @Umbraco.RenderMacro("SliderImages")
            </ul>
           </div>
         </div>
          <div class="col3-3 white white-bottom auto">
            <div class="next-to-icon">
              <h2>@page.projectName</h2>
              <p>@page.descriptionContent</p>
            </div>
          </div>
        </div>
    

    How will I create the macro in order to pull the images into the slider?

    Please advise

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Mar 31, 2016 @ 11:22
    Dennis Adolfi
    1

    Hi Willem.

    If there is a Macro you want i´d suggest to add a macro parameter to your macro, of the type Multiple Media Picker. Then select the images you´d like to display, then in you macro you get the id:s of your selected images like so:

    var mediaIds = Model.MacroParameters["mediaIds"];
    

    Tip: Take a look at the macro snippet for the macro Gallery and you get a pretty good idea of how to create that type of macro.

    enter image description here

    Another way if doing it is to instead of creating a macro you create a partialview. And in that partialview you fetch the images from your doctype that you´d like to display:

    Partialview example:

    @inherits UmbracoTemplatePage
    
    
                                @foreach (var slide in CurrentPage.Slider.Slides)
                                {
    
                                        <img src="@slide.Image" alt="">                                       
                                }   
    
  • 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