Forums

Give help. Get help.

  • # September 11, 2017 at 1:03 am

    Hi

    I am using this slider on sharepoint 2013 and created library with columns for banner images text and wanted to add a hyper link on banners.

    I have tried and place a condition if banner link is in the column add the hyper link otherwise just show banner without hyperlink
    I have created a hyper link column and try to use it in the code but it some how not showing all banners.
    it only shows first 7 banners.

    here is my code.

    /SiteAssets/SliderJS/unslider-min.js

        jQuery(document).ready(function($) {
           var sliderList = "Slider"; // Name of the list that contains slides
           var slideContentField = "HTML"; //Name of the Rich text field that has slide content
    
           var slideBackgroundImageField = "Picture"; //Name of the picture field to use as background image
           var slideHyperlink = "BannerLink"; //Name of the hyperlink field to use as banner link
    
           HillbillySlider(sliderList,slideContentField,slideBackgroundImageField,slideHyperlink);
       });
    

    function HillbillySlider(sliderList,slideContentField,slideBackgroundImageField,slideHyperlink) {

          //query to retrieve all items
          var query = "";
    
          //return fields for slide content and background picture
          var camlViewFields = "";
    
          $().SPServices({
               operation: "GetListItems",
               async: true,
               listName: sliderList,
               CAMLViewFields: camlViewFields,
               CAMLQuery: query,
               completefunc: function(xData, Status) {
                    $(xData.responseXML).SPFilterNode("z:row").each(function() {
                    var slideContent = ($(this).attr("ows_"+slideContentField));
                    var picture = $(this).attr("ows_"+slideBackgroundImageField)==null?"":$(this).attr("ows_"+slideBackgroundImageField).split(",")[0];
    
    
                    var BannerLink = $(this).attr("ows_"+slideHyperlink)==null?"22":$(this).attr("ows_"+slideHyperlink).split(",")[0];
    
                    //alert(BannerLink);
    
    
                    if (BannerLink === "22")
                    {
                        //create slide (li) and append it to other slides
    
                        $("#hillbillySlider").append("<li>
    "+slideContent+"
    </li>"); } else { //create slide (li) and append it to other slides $("#hillbillySlider").append("<a href='"+BannerLink+"' target='_self'><li>
    "+slideContent+"
    </li></a>"); // $("#hillbillySlider").append("<li>
    "+slideContent+"
    </li>");

    //
    }

               }); // end completefunc
               //start the slider
               $('.hillbillyBanner').unslider();
             }
          }); // end SPServices call
      }
    

      Any help would be greatly appreciated

    Viewing 16 post (of 16 total)

    You must be logged in to reply to this topic.

    icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag