SharePoint 2013:已提升的链接换行图块

时间:2016-10-14 09:15:25

标签: javascript css sharepoint

我们已经实现了一个解决方案,可以在提升的链接中包装切片,如下文所述:

SharePoint 2013: Promoted Links Wrap Tiles

这适用于我们,但现在我们想要使用多个提升的链接列表。在technet页面,有人已经要求我们需要的相同的东西,但是还没有答案。我注意到我们获得了与具有相同请求的人相同的Web部件ID,即:WebPartWPQ4。

通过脚本自己,我想我需要修改找到提升的链接项的行:

var numberOfPromotedLinks = $('.ms-promlink-body > .ms-tileview-tile-  root').length;

我试着像这样修改它:

var numberOfPromotedLinks = $('#WebPartWPQ4 > .ms-promlink-body > .ms-tileview-tile-root').length;

然而,这不起作用。

1 个答案:

答案 0 :(得分:0)

  1. 单击齿轮,编辑页面
  2. 选择“插入标签”
  3. 选择网络部件
  4. 在“类别”列中 - 单击“媒体和内容”
  5. 在“部件”列中 - 单击“脚本编辑器”
  6. 在右侧 - 点击添加
  7. 在“新建”脚本编辑器“Box(可能[2])中,单击右上角显示的向下箭头,然后单击”编辑Web部件“。
  8. 然后单击出现的EDIT SNIPPET。
  9. 将以下文字粘贴到“嵌入”框中:
  10. <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.min.js  "></script>
    
    <script type="text/javascript">
    $(document).ready(function () {
    
    // Update this value to the number of links you want to show per row
    
    var numberOfLinksPerRow = 3;
    
    // local variables
    
    var pre = "<tr><td><div class='ms-promlink-body' id='promlink_row_";
    var post = "'></div></td></tr>";
    var numberOfLinksInCurrentRow = numberOfLinksPerRow;
    var currentRow = 1
    
    // find the number of promoted links we're displaying
    var numberOfPromotedLinks = $('.ms-promlink-body > .ms-tileview-tile-root').length;
    
      // if we have more links then we want in a row, let's continue
      if (numberOfPromotedLinks > numberOfLinksPerRow) {
    
        // we don't need the header anymore, no cycling through links
        $('.ms-promlink-root > .ms-promlink-header').empty();
    
        // let's iterate through all the links after the maximum displayed link
        for (i = numberOfLinksPerRow + 1; i <= numberOfPromotedLinks; i++) {
    
          // if we're reached the maximum number of links to show per row, add a new row
          // this happens the first time, with the values set initially
          if (numberOfLinksInCurrentRow == numberOfLinksPerRow) {
    
            // i just want the 2nd row to
            currentRow++; 
    
            // create a new row of links
            $('.ms-promlink-root > table > tbody:last').append(pre + currentRow + post);
            // reset the number of links for the current row
            numberOfLinksInCurrentRow = 0    }    // move the Nth (numberOfLinksPerRow + 1) div to the current table row
    
        $('.ms-promlink-body > .ms-tileview-tile-root:nth-child(' + (numberOfLinksPerRow + 1) + ')').appendTo($('#promlink_row_' + currentRow));
    
        // increment the number of links in the current row
        numberOfLinksInCurrentRow++;  }
    }
    });
    </script>
    
相关问题