当前位置:编程学习 > html/css >>

Add Script Editor and Content Editor Web Part via powershell

Add Script Editor Web Part :
I had coding a function about adding scripteditorwebpart to page, here is the examplt to call function:
 
AddScriptEditorWebPart "http://localhost" "/SitePages/Home.aspx" "JSFile.js"
 
  function AddScriptEditorWebPart($siteUrl, $pageUrl, $jsLink){ $webPartProperty_Visible = $true $web = get-spweb $siteUrl $defaultPage = $web.GetFile($pageUrl) # Get the LimitedWebPartManager $webpartmanager=$defaultPage.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) #Create fancy GUID $lvwpGuid1 = [System.Guid]::NewGuid().ToString() $lvwpKey = "g_" + $lvwpGuid1.Replace("-","_") # Instantiate wp $lvwp =New-Object Microsoft.SharePoint.WebPartPages.ScriptEditorWebPart $lvwp.ID = $lvwpKey $code = "$" $lvwp.Content = @" <script src="http://code.jquery.com/jquery-2.0.3.min.js" ></script> <script type="text/javascript" src="$jsLink"></script> "@ $lvwp.Title = "DocumentReadyForNewOrUpdatePost" $lvwp.Visible = $webPartProperty_Visible $lvwp.ChromeType = "None" $lvwp.HorizontalAlign = "Center" # Add the web part $webpartmanager.AddWebPart($lvwp, "Main", 0); # Update the web $web.Update(); write-host "success" $web.Dispose() write-host "Done" }

 

 
Add Content Editor Web Part :
AddScriptEditorWebPart "http://localhost" "/SitePages/Home.aspx" "file.txt"
 
  function AddContentEditorWebPart($siteUrl, $pageUrl, $conetntLink){ $webPartProperty_Visible = $true $web = get-spweb $siteUrl $defaultPage = $web.GetFile($pageUrl) # Get the LimitedWebPartManager $webpartmanager=$defaultPage.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) #Create fancy GUID $lvwpGuid1 = [System.Guid]::NewGuid().ToString() $lvwpKey = "g_" + $lvwpGuid1.Replace("-","_") # Instantiate wp $lvwp =New-Object Microsoft.SharePoint.WebPartPages.ContentEditorWebPart $lvwp.ID = $lvwpKey $code = "$" $lvwp.ContentLink = @" $conetntLink "@ $lvwp.Title = "DocumentReadyForNewOrUpdatePost" $lvwp.Visible = $webPartProperty_Visible $lvwp.ChromeType = "None" $lvwp.HorizontalAlign = "Center" # Add the web part $webpartmanager.AddWebPart($lvwp, "Main", 0); $web.Update(); $web.Dispose() }

 

 
 
 
补充:web前端 , HTML/CSS  ,

上一个:rnqoj-49-加分二叉树-(区域动归+记忆化)
下一个:使用spring-amqp结合使用rabbitmq

更多html/css疑问解答:
div+css中关于ie浏览器中非啊元素的:hover的实现问题,哪位大神指点下啊
css jquery代码中为什么宽度这样设定.menu li ul 150px;.menu li ul a 110px;.menu li a中padding的20px
css 属性选择器 ie6 不支持吗?
用css、jquery做的选项卡效果,有一个小疑问,请高手指点,代码如下:
介绍本学习css的书
wordpress多个CSS样式怎么调用?
这个div 的css是如何编写的
div+css中,div的右边框小于div的高度且居中,除了用背景图片,如何实现?
表格立体感用CSS怎么写 我要 具体代码 写仔细 分段的 谢谢 了 兄弟 还有 下拉列表框 立体感用CSS 怎么写
CSS 在一个大的DIV里面,另一个DIV怎么居中并置底。
dw中html文档为什么无法链接css文档
设计一个小例子说明DIV+CSS的优势(例子要解释并注释)。
我会html css目前正在学js,打算在大三的寒假找个实习,请问应该找哪方面的实习?
css问题,跪求大大帮忙
请教网页设计高手,如下图的这种css代码怎么写?
asp
php
Delphi
Matlab
JSP
Foxpro
JS
C/C++
C#/ASP.NET
VC++
JAVA
VB
汇编语言
html/css
CGI
XML/UML
wap
网站相关
网页素材
python
微信小程序
thinkphp
如果你遇到编程学习难题:
访问www.zzzyk.com 试试
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,