亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

MOSS 2007 應用隨筆系列:自定義moss菜單匯總

系統 1622 0
?

一.自定義文檔庫/列表庫中項目的右鍵關聯菜單

  原始菜單如下圖所示:

?

MOSS 2007 應用隨筆系列:自定義moss菜單匯總

  下面開始我們本次的工作歷程:

  首先,找到C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATELAYOUTS這個目錄下的2052目錄(這個默認是中文版本的路徑,英文版本的MOSS是1033目錄),其中有個core.js的JS文件,MS已經給我們預留了自定義的接口來實現我們自己的菜單定義了

  添加以下兩個JS的函數代碼:

funtion AddListMenuItems(m,ctx)
{
if(typeof(Custom_AddListMenuItems) != "undefined")
{
 if(Custom_AddListMenuItems(m,ctx))
 return;
}
}

funtion AddDocLibMenuItems(m,ctx)
{
if(typeof(Custom_AddListMenuItems) != "undefined")
{
 if(Custom_AddListMenuItems(m,ctx))
 return;
}
}

  然后我們實現自定義函數AddListMenuItems(列表庫)和AddDocLibMenuItems(文檔庫)

  ,在頁面右上角點擊‘網站操作’--編輯網頁--添加Webpart部件,選擇

?

  點擊Webpart部件右邊的‘編輯’--修改共享Webpart部件

?

MOSS 2007 應用隨筆系列:自定義moss菜單匯總

  在頁面中點擊‘源編輯器’

  ,在彈出的窗口中添加自定義函數AddListMenuItems(列表庫)和AddDocLibMenuItems(文檔庫)

<script language="javascript">
function Custom_AddDocLibMenuItems(m, ctx)
{
  strDisplayText = "報表統計";
  var rootMenu = CASubM(m,strDisplayText,"","",500);
  strDisplayText = "匯總表";
  strAction = "STSNavigate('~site/_layouts/ItemAudit.aspx?ItemId={ItemId}&amp;ListId={ListId}')";
  strImagePath=ctx.imagesPath+"oisweb.gif";
  menuOption = CAMOpt(rootMenu,strDisplayText,strAction,strImagePath);
  menuOption.id = "ID_MySubMenu";

  //var rootMenu = CASubM(m,strDisplayText,"","",500);
  strDisplayText = "數字統計表";
  strAction = "STSNavigate('~site/_layouts/ItemAudit.aspx?ItemId={ItemId}&amp;ListId={ListId}')";
  strImagePath=ctx.imagesPath+"oisweb.gif";
  menuOption = CAMOpt(rootMenu,strDisplayText,strAction,strImagePath);
  menuOption.id = "ID_MySubMenu";

  strDisplayText = "行列匯總表";
  strAction = "STSNavigate('~site/_layouts/ItemAudit.aspx?ItemId={ItemId}&amp;ListId={ListId}')";
  strImagePath=ctx.imagesPath+"oisweb.gif";
  menuOption = CAMOpt(rootMenu,strDisplayText,strAction,strImagePath);
  menuOption.id = "ID_MySubMenu";

  strDisplayText = "并列匯總表";
  strAction = "STSNavigate('~site/_layouts/ItemAudit.aspx?ItemId={ItemId}&amp;ListId={ListId}')";
  strImagePath=ctx.imagesPath+"oisweb.gif";
  menuOption = CAMOpt(rootMenu,strDisplayText,strAction,strImagePath);
  menuOption.id = "ID_MySubMenu";

  return false;
}
</script>

  點擊保存--應用--確定--退出編輯模式

  好,看到我們期待已久的最終結果,

MOSS 2007 應用隨筆系列:自定義moss菜單匯總

注意,這里是List和Doc是2個分別的JS方法名。?

?

?

?

?

這個菜單是用Feature部署上去的功能,先提一下Feature的作用:

  微軟在MOSS中利用Feature的特性,可以將Feature.xml中以特定格式描述的功能部署到MOSS中,這些功能包括工作流,菜單項,網站欄、內容類型...等等。然后可以在MOSS中配置啟用或者停用這些功能,由于這個特性不需要進行代碼開發,只需要配置Feature.xml和其中指定的另一個xml,方法簡單可行。

  Feature.xml如下:

<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="6098EC11-8128-409A-8D2C-414E93F67DD4"

      Title="add my menu"

      Description="this is a custom menu"

      Version="1.0.0.0"

      Scope="Site"

      Hidden="FALSE"

      DefaultResourceFile="customDocumentLibrary"

      xmlns="http://schemas.microsoft.com/sharepoint/
">

      <ElementManifests>

        <ElementManifest Location="elements.xml" />

      </ElementManifests>

</Feature>

  解釋一下其中的內容,Id是GUID類型標示的唯一值,可以由VS自帶的GUID Generator來生成,Tiltle是功能標題,Version是版本號,Description:對description的描述,Scope:其值可以是Web或Site,它指明了這個Feature是應用于整個的Site Collection還是僅僅用于單獨的一個子站點。Hidden:值可以是True或False.該設置指定了這個Feature是否在Site Feature頁面上顯示。DefaultResourceFile: 資源文件名字,Feature依賴它提供其它附加的配置信息。

Feature.xml文件中的<ElementManifests>元素,這個元素包含了另一個XML文件的位置,而這個文件包含的<Elemnets>的內容是Feature要實現的。

  <ElementManifest>元素指明了要使用一個名為ProvisionedFiles.xml的文件,以下是該文件的<Elements>元素內容。

  下面是Feature.xml中指定的elements.xml內容:

<Elementsxmlns="http://schemas.microsoft.com/sharepoint/">
<!-- create command link site setting page -->
<CustomAction Id="SiteSettings" GroupId="Customization"
        Location="Microsoft.SharePoint.SiteSettings"
              Sequence="106"
              Title="Custom Litware Site Setting Command">
              <UrlAction Url="/_layouts/litwarefeaturelab.aspx?command=SiteSettingCommand"/>
   </CustomAction>
   <!--Add command to site action dropdow -->
    <CustomActionId="SiteActionsToolbar111111111111"

            GroupId="SiteActions"
                  Location="Microsoft.SharePoint.StandardMenu"
                  Sequence="1000"
                  Title="Litware custom Action"
                  Description="custom litware site action"
                  ImageUrl="/_layouts/images/ACL16.GIF">
                  <UrlAction Url="/_layouts/litwarefeaturelab.aspx?command=SiteActionCommand"/>
  </CustomAction>
    <!-- Document Library Toolbar New Menu DropDown-->
    <CustomAction Id="DocLibNewToolbar"
        RegistrationType="List"
           RegistrationId="101"
           GroupId="NewMenu"
           Rights="ManagePermissions"
           Location="Microsoft.SharePoint.StandardMenu"
           Sequence="1000"
           Title="Litware Custom New Command"
           Description="THis Command Creates a new Litware doc"
           ImageUrl="/_layouts/images/ACL16.GIF">
           <UrlAction Url="/_layouts/litwarefeaturelab.aspx?command=NewDocCommand"/>
  </CustomAction>
    <!-- Document library Toolbar Actions Menu Dropdown-->
    <CustomAction Id="DocLibActionsToolbar"
        RegistrationType="List"
           RegistrationId="101"
           GroupId="ActionsMenu"
           Rights="ManagePermissions"
           Location="Microsoft.SharePoint.StandardMenu"
           Sequence="1000"
           Title="Litware Command on Document Library"
           Description="THis Command Creates a new Litware doc"
           ImageUrl="/_layouts/images/ACL16.GIF">
           <UrlAction Url="/_layouts/litwarefeaturelab.aspx?command=DocLibCommand"/>
     </CustomAction>
     <CustomActionId="ECBItemToolbar"
        RegistrationType="List"
           RegistrationId="101"
           Type="ECBItem"
           Location="BugWorkaround:LocationShouldEqualEditControlBlock"
           Sequence="106"
           Title="Litware ECB item Command">
           <UrlActionUrl="/_layouts/litwarefeaturelab.aspx?command=SiteSettingCommand"/>
     </CustomAction>
</Elements>

其中第一個CustomAction在Site Setting頁面中的LOOK AND FEEL標題下創建了一個自定義鏈接.第二個CustomAction在頁面的Site Action菜單下增加了一個用戶自定義菜單項.第三個CustomAction在文檔庫的New下拉菜單下創建了一個自定義菜單項.第四個CustomAction在文檔庫的Action下拉菜單下創建了一個自定義菜單項.

  注意第五個CustomAction本來是在文檔庫的每個列表項的菜單上增加一個菜單項,但是不知什么原因不能正確加入,有待進一步的研究.

  再做倆個批處理文件來部署和卸載這個Feature

  部署批處理文件InstallFeature.bat

@rem======================================================================
@rem
@rem  InstallFeature.bat
@rem
@rem======================================================================
@echo off
setlocal
pushd .
goto InstallFeature
@rem----------------------------------------------------------------------
@rem  InstallFeature
@rem----------------------------------------------------------------------
:InstallFeature
  set SPAdminTool=%CommonProgramFiles%Microsoft Sharedweb server extensions12BINstsadm.exe
  set TargetUrl=http://huijianming
  set FeaturePath=menuFeature.xml
  echo InstallFeature %FeaturePath%
  "%SPAdminTool%" -o installfeature -filename %FeaturePath% -force
  echo Activating feature %FeaturePath%
  "%SPAdminTool%" -o activatefeature -filename %FeaturePath% -url %TargetUrl% -force
  echo iisreset
  iisreset

 卸載批處理文件UnInstallFeature.bat

@rem======================================================================
@rem
@rem  UnInstallFeature.bat
@rem
@rem======================================================================
@echo off
setlocal
pushd .
goto UnInstallFeature
@rem----------------------------------------------------------------------
@rem  UnInstallFeature
@rem----------------------------------------------------------------------
:InstallFeature
  set SPAdminTool=%CommonProgramFiles%Microsoft Sharedweb server extensions12BINstsadm.exe
  set TargetUrl=http://huijianming
  set FeaturePath=menuFeature.xml
  echo InstallFeature %FeaturePath%
  "%SPAdminTool%" -o UnInstallFeature-filename %FeaturePath% -force
  echo iisreset
  iisreset

  將以上的兩個XML放到Menu的文件夾中,然后將文件夾拷貝到C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATEFEATURES

  運行部署批處理文件

?

MOSS 2007 應用隨筆系列:自定義moss菜單匯總

  效果圖如下:

  文檔庫新建菜單

?

MOSS 2007 應用隨筆系列:自定義moss菜單匯總 ?

  文檔庫操作菜單

?

MOSS 2007 應用隨筆系列:自定義moss菜單匯總

  網站操作菜單

?

MOSS 2007 應用隨筆系列:自定義moss菜單匯總

  運行卸載批處理文件

? MOSS 2007 應用隨筆系列:自定義moss菜單匯總

MOSS 2007 應用隨筆系列:自定義moss菜單匯總


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 久久国产免费一区二区三区 | 久热官网 | 免费99视频| 伊人77| 久久精品a| 天天射天天 | 亚洲女人逼| 国产一区精品 | 久久99精品久久久久久h | 日本一区二区三区高清福利视频 | 亚洲天天在线日亚洲洲精 | 亚洲国产精品视频在线观看 | 欧美久久久久久 | 久久夜夜操 | 黑人巨大精品战中国美女 | 大狠狠大臿蕉香蕉大视频 | 国产福利视频在线 | 狠狠操夜夜操 | 国产成人在线免费观看 | 久久福利影院 | 91热在线观看精品 | 成人网在线观看 | 色片在线免费观看 | 自拍偷自拍亚洲精品被多人伦好爽 | 久热爱免费精品视频在线播放 | 伊人情人综合成人久久网小说 | 婷婷综合激情五月中文字幕 | 视频一区久久 | 久久久久久麻豆 | 麻豆国产原创 | 国产精品久久久亚洲第一牛牛 | 中文字幕一区二区三区四区五区人 | 人色在线视频 | 精品视频中文字幕 | 色的综合 | 亚洲综合图片小说区热久久 | 国产精品视频999 | 激情五月婷婷红人馆 | 亚洲视频综合网 | 婷婷四房综合激情五月在线 | 五月桃花网婷婷亚洲综合 |