문제

salvete!PowerShell을 통해 Wiki 홈 페이지에 WebPart를 추가 할 수 있습니까?나는 집안일에 웹 파트를 추가 해야하는 100 개의 사이트를 가지고 있습니다.정상적인 웹 파트 페이지로 쉽게 가능할 수 있습니다. 그러나 Wiki-홈 페이지는 어떨까요?

도움이 되었습니까?

해결책

Yes, it's possible. I had a blog post on this very topic, but the blog site has since been deactivated. Basically you do it like you would add a web part to any other Web Part Page. When it's time to specify the zone, use the "wpz" zone. Also, you need to add some markup to the Page's "WikiField" that resembles this (substituting your Web Part ID Guid where appropriate):

<div class="ms-rtestate-read ms-rte-wpbox">
  <div class="ms-rtestate-read {webpart ID guid}"
       id="div_{webpart ID guid}">
  </div>
  <div class="ms-rtestate-read"
       id="vid_{webpart ID guid}"
       style="display: none">
  </div>
</div>

This posting was similar to the content I presented in my (now deleted) posting: http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/

다른 팁

Below Code Reads the SiteUrls from Text file called SiteUrls.txt, and add library called "Oct Invoicing 2014" to the Wikipage called "Billing_Req.aspx"

Here we are taking variable i to check for the library already present on the page, if present we are incrementing i to 1 and else its default value =0

If i=0 means webpart is not present on the page and it will be added on the page.

in All the cases we are writing the output to D:\Webpartoutput.txt.

cls 

asnp "*sh*"

$file=Get-Content -Path D:\SiteUrls.txt

foreach($url in $file)
 {

$web= Get-SPWeb -Identity $url

$listName = "Oct Invoicing 2014"

$pageUrl= $web.GetFile("SitePages/Billing_Req.aspx");

if($pageUrl.Exists)
{

    try
     {

    $i=0; 

    $webpart = New-Object Microsoft.SharePoint.WebPartPages.XsltListViewWebPart

    $list=$web.Lists.TryGetList($listName)

    $webpart.ListId = $list.ID

    $webpart.ViewGuid = ($list.DefaultView.ID).ToString("B").ToUpper()  

    $webpartmanager=  $web.GetLimitedWebPartManager($pageUrl,[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

    foreach($wpt in $webpartmanager.WebParts)
    {

         if($wpt.ListId -eq $list.ID)
         {
         $i=$i+1;
         break;

         }
    }

    if($i -eq "0")
    {

        $webpartmanager.AddWebPart($webpart,"",0)

       "Webpart Added Successfully" + $url + " " + $webpart.Title |  Out-File   -Append -FilePath D:\WebpartOuPut.txt
     }
     else
      {
         " Dude Webpart is already present on the site  : " + $url |  Out-File -Append -FilePath D:\WebpartOuPut.txt 
      }
  }

  catch [Exception]
      {

   $url + $_.Exception.Message | Out-File -Append -FilePath D:\WebpartOuPut.txt 
     }
    }
          else
    {
    "Page Url is invalid or not existing  : " + $url  | Out-File -Append -FilePath D:\WebpartOuPut.txt 
    }
 }

More details in my blog

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top