Sharepoint Branding - 多文件配置

时间:2009-08-12 19:09:42

标签: sharepoint branding

我在sharepoint中创建了一个带有大量图片的自定义母版页(比如200)。如何将要配置的所有文件打包到网站集的样式库中?我知道这样做的唯一方法是通过一个功能,但这意味着将每个文件(所有200个文件)列为<file></file>元素。有没有更简单的方法?属性IncludeFolders =“?? - ??”在<module></module>中似乎没有做任何事情。

如果所有图像文件都在我的功能文件夹中的文件夹中(例如... \ template \ features \ myFeature \ images),有没有办法将整个文件夹配置到样式库?

感谢。

2 个答案:

答案 0 :(得分:4)

此module.xml文件位于名为“Images”的文件夹中。所有图片也都在此文件夹中(使用visual studio 2008 v1.3的sharepoint开发工具)。 wsp包需要知道正在添加的所有文件,因此您必须添加每个文件。 (将.wsp重命名为.cab并打开它。然后您可以看到解决方案中的所有文件)

 <Elements Id="8f8113ef-75fa-41ef-a0a2-125d74fc29b7" xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Images" Url="Style Library/Images/myfolder" RootWebOnly="TRUE">
    <File Path="hvi_logo.bmp" Url="hvi_logo.bmp" Type="GhostableInLibrary" />
    <File Path="hvi_logo_small.bmp" Url="hvi_logo_small.bmp" Type="GhostableInLibrary" />
    <File Path="epj-logo.png" Url="epj-logo.png" Type="GhostableInLibrary" />
  </Module>
</Elements>

你可以用一个小的C#应用​​程序为你创建xml文件,如下所示:

 var info = new DirectoryInfo(@"c:\pathToImageFolder");
        var files = info.GetFiles();

        TextWriter writer = new StreamWriter(@"c:\pathToImageFolder\module.xml");

        writer.WriteLine("<Elements Id=...");
        foreach (FileInfo file in files)
        {
            writer.WriteLine(string.Format("<File Path='{0}' Url='{0}' Type='GhostableInLibrary' />",file.Name));
        }
        writer.WriteLine("</Elements>");
        writer.Flush();
        writer.Close();

答案 1 :(得分:1)

这是一个适合我的快速Powershell功能:

function Enum-FilesInPath
{
    param([string]$path)

    Get-ChildItem -path $path | foreach-object {
        # if a directory, recurse...
        if ($_.PSIsContainer)
        {
            $recursivePath = [string]::Format("{0}\{1}", $path, $_.Name)
            Enum-FilesInPath $recursivePath
        }
        # else if a file, print out the xml for it
        else
        {
            $finalPath = [string]::Format("{0}\{1}", $path, $_.Name)
            $url = $finalPath.Replace("\", "/") # backslashes for path, forward slashes for urls
            [string]::Format("`t<File Url=`"$url`" Path=`"$fullPath`" Type=`"GhostableInLibrary`" />")
        }
    }
}
相关问题