Webパーツの開発については、すでに以前に記述されていましたが、実際にはそれらが必要な理由も記述されています: habrahabr.ru/blogs/sharepoint/57992
この記事では、単にメッセージを表示するWebPartを作成します。 例として、それ自体は有益で疑わしいものではありませんが、一般的なメカニズムを示すタスクは非常に一貫しています。
必要なもの
それほどではない:
1. MS SharePointサービス3.0へのアクセスとWebデスクでページを編集する機能(実験用)
2. XML /テキストエディター
なぜxml / xslですか?
このマゾヒズムの主な利点は、簡単なインストールです。
してはいけないこと:
アセンブリをどこにも置かないでください
どこにでもアセンブリを登録する必要はありません
設定を編集する必要はありません
このようなWebパーツのインストールは、SharePoint Webインターフェイスのみを使用して簡単に行えます。
方法
このプロセスは、不必要な詳細なしで簡単に説明されます。
それでは始めましょう。
.webpartファイルを作成する
お気に入りのXMLエディターを開き(VS 2008を使用)、Webパーツの「空白」を作成します。
< webParts >
< webPart xmlns ="http://schemas.microsoft.com/WebPart/v3" >
< metaData >
< type name ="Microsoft.SharePoint.WebPartPages.DataFormWebPart, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
< importErrorMessage > Cannot import this Web Part. </ importErrorMessage >
</ metaData >
< data >
< properties >
< property name ="MissingAssembly" type ="string" > Cannot import this Web Part. </ property >
< property name ="FireInitialRow" type ="bool" > True </ property >
< property name ="TitleIconImageUrl" type ="string" />
< property name ="HelpMode" type ="helpmode" > Modeless </ property >
< property name ="CacheXslStorage" type ="bool" > True </ property >
< property name ="ViewContentTypeId" type ="string" />
< property name ="Description" type ="string" />
< property name ="DataSourcesString" type ="string" > NotSet </ property >
< property name ="AllowZoneChange" type ="bool" > True </ property >
< property name ="ParameterBindings" type ="string" null ="true" />
< property name ="PageSize" type ="int" > -1 </ property >
< property name ="TitleUrl" type ="string" />
< property name ="ViewFlag" type ="string" > 0 </ property >
< property name ="NoDefaultStyle" type ="string" > TRUE </ property >
< property name ="Direction" type ="direction" > NotSet </ property >
< property name ="UseSQLDataSourcePaging" type ="bool" > True </ property >
< property name ="ListName" type ="string" null ="true" />
< property name ="Hidden" type ="bool" > False </ property >
< property name ="DisplayName" type ="string" />
< property name ="SampleData" type ="string" null ="true" />
< property name ="HelpUrl" type ="string" />
< property name ="ChromeType" type ="chrometype" > Default </ property >
< property name ="CatalogIconImageUrl" type ="string" />
< property name ="DataFields" type ="string" />
< property name ="Default" type ="string" />
< property name ="ChromeState" type ="chromestate" > Normal </ property >
< property name ="DataSourceID" type ="string" />
< property name ="AllowClose" type ="bool" > True </ property >
< property name ="CacheXslTimeOut" type ="int" > 86400 </ property >
< property name ="AllowMinimize" type ="bool" > True </ property >
< property name ="AllowEdit" type ="bool" > True </ property >
< property name ="XslLink" type ="string" null ="true" />
< property name ="ShowWithSampleData" type ="bool" > False </ property >
< property name ="ExportMode" type ="exportmode" > All </ property >
< property name ="AllowHide" type ="bool" > True </ property >
< property name ="AllowConnect" type ="bool" > True </ property >
< property name ="Title" type ="string" > HabraSample </ property >
< property name ="Width" type ="string" > 500px </ property >
< property name ="Height" type ="string" > 400px </ property >
< property name ="Xsl" type ="string" ></ property >
</ properties >
</ data >
</ webPart >
</ webParts >
* This source code was highlighted with Source Code Highlighter .
実際、次のプロパティに興味があります。
< property name ="Title" type ="string" > HabraSample </ property >
< property name ="Width" type ="string" > 500px </ property >
< property name ="Height" type ="string" > 400px </ property >
< property name ="Xsl" type ="string" ></ property >
* This source code was highlighted with Source Code Highlighter .
最初はWebパーツの名前です。 2番目と3番目は理解可能であり、4番目ではXSLを記述します。
最も簡単なものを書きましょう:
xsl:stylesheet version ="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" xmlns:ddwrt2 ="urn:frontpage:internal" >
< xsl:output method ="html" version ="1.0" encoding ="UTF-8" indent ="yes" />
< xsl:template match ="/" xmlns:ddwrt ="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" >
Hello, Habr!
</ xsl:template >
</ xsl:stylesheet >
*このソースコードは、 ソースコードハイライターで強調表示されました。
次に、XSLをWebパーツに追加します。
< property name ="Xsl" type ="string" >
<! [CDATA[ < xsl:stylesheet version ="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" xmlns:ddwrt2 ="urn:frontpage:internal" >
< xsl:output method ="html" version ="1.0" encoding ="UTF-8" indent ="yes" />
< xsl:template match ="/" xmlns:ddwrt ="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" >
Hello, Habr!
</ xsl:template >
</ xsl:stylesheet > ]] ></ property >
* This source code was highlighted with Source Code Highlighter .
それだけです xmlを拡張子.webpartのファイル(たとえば、Habr.webpart)に保存します。
ここからコードを完全にダウンロード/表示できます:
anychart.com/batsuev/habrahabr/sharepoint-1/habr.webpart
Webパーツをページに追加する
すべてが非常に簡単です。 Webパーツページを開き、編集モードに移動します。
[Webパーツの追加]をクリックして、[高度なWebパーツギャラリーとオプション]を選択します。
[参照]の右ペインで、インポートに切り替えます。
Webパーツがアップロードされ、次のように表示されます。
次に、ページにドラッグアンドドロップするだけです。
クジラ:
あとがき
このようなWebパーツの作成中に遭遇した最大の問題:それらの通常のドキュメントが見つかりませんでした。
私は記事が好きなら、私はについて書くことができます:
1. Webパーツを配置する場所と、すべてのページからアクセスできるように登録する方法。
2.このようなWebPartsのインストーラーを作成します(ここで行ったように: www.anychart.com/products/sharepoint/demos/installation.php )
3. xml / xslを使用したさまざまなデータへのアクセス(たとえば、データベース、リストなど)
さて、またはこれに関連する何か。