Sharepoint 品牌 - 多文件配置

发布于 2024-08-01 21:30:49 字数 352 浏览 5 评论 0原文

我在 sharepoint 中创建了一个自定义母版页,其中包含大量图像(例如 200 个)。 如何打包要配置到网站集样式库的所有文件? 我知道做到这一点的唯一方法是通过一个功能,但这意味着将每个文件(全部 200 个)列为 元素。 有更容易的方法吗? 属性 IncludeFolders="??-??" 在 中似乎没有做任何事情。

如果所有图像文件都位于我的功能文件夹内的一个文件夹中(例如...\template\features\myFeature\images),是否有办法将整个文件夹提供给样式库?

谢谢。

I've created a custom master page in sharepoint that comes with a lot of images (say 200). How do I package all the files to be provisioned to the Style Library of a site collection? The only way I know to do this is through a feature but that means listing every single file (all 200 of them) as a <file></file> element. Is there an easier way? The attribute IncludeFolders="??-??" in <module></module> doesn't seem to do anything.

If all the image files are in a folder inside my feature folder (e.g. ...\template\features\myFeature\images), is there a way to provision the entire folder to the Style Library?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

べ映画 2024-08-08 21:30:49

此 module.xml 文件位于名为“Images”的文件夹中。 所有图片也都在这个文件夹中(使用的是sharepoint开发工具 for Visual Studio 2008 v1.3)。 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();

This module.xml file is in a folder named "Images". All the pictures are also in this folder (using the sharepoint development tools for visual studio 2008 v1.3). The wsp package need to know all the files that is adding so you have to add each file. (rename the .wsp to .cab and open it. You can then see all the files in the solution)

 <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>

You could wirte a small C# app to create the xml file for you, something like this:

 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();
灰色世界里的红玫瑰 2024-08-08 21:30:49

这是一个适合我的快速 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`" />")
        }
    }
}

Here's a quick Powershell function that works for me:

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`" />")
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文