SharePoint - 具有文件夹结构的自定义文档库
我有一个带有内容类型的自定义文档库模板。这工作正常,但我想添加的唯一一件事是,当用户基于该模板实例化新文档库时,它已经具有预定义的文件夹结构。
我尝试在 schema.xml 中添加模块标签,但这似乎不起作用。
我知道可以使用 ListInstance 功能提供包含文件和文件夹的文档库,但在这种情况下这是不可能的。我希望预定义的文件夹结构是文档库模板的一部分。
这可能吗?
谢谢马丁
I have a custom document library template with content types. This works fine but the only thing that I would like to add is that when a user instantiates a new document library based on that template, that is has a predefined folder structure already in place.
I have tried adding Module tags in my schema.xml but this doesn't seem to work.
I know that it is possible to provision a document library with files and folders with a ListInstance feature but this is not possible in this case. I would like that the predefined folder structure is part of the document library template.
Is this possible?
Thanks
Maarten
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想使用文档库定义来实现此目的。我认为这是不可能实现的。您可以做的是借助列表/文档库模板。
1 按照您想要的方式创建自定义文档库。
2. 创建所需的文件夹结构。无需上传任何文件。
3,通过 Doclibray 设置将文档库另存为模板(确保将模板与存储在其中的内容一起存储)
If You want to achieve this using Document Library Definition. I don't think that would be achievable. What you can do is take help of list /document library templates.
1 Create a custom Doclibary the way you want.
2. create the desired folder structure. without uploading any documents.
3, Save the doc library as template by going to Doclibray settings ( make sure you store the template along with content stored into it)
另一种方法(我很快就会在博客上介绍)是伪造列表创建事件。我将带有自定义 aspx 页面的空视图定义添加到列表模板中。自定义页面只是在列表上执行一些自定义功能,删除初始化视图,然后重定向到普通视图。它有点混乱,只有通过 UI 创建列表时它才会起作用,但它确实有效。
这是一个非常简单的例子。您已经有了列表模板。在 schema.xml 文件中,向 Views 元素添加一个新视图,如下所示:
您可以不使用其中的空元素。这是我在写博客之前要进一步测试的东西。但这将完成工作。重要的是:
对于自定义页面(在我的示例中为 init.aspx),我只是复制了 ...\12\TEMPLATE\Pages\viewpage.aspx 并更改了页面继承的内容。您可以使用内联代码来完成此操作,但我使用了代码隐藏程序集。因此该文件的第一行变为:
然后是隐藏代码:
基本上,我们依靠 SharePoint 默认行为来显示创建后的列表的默认视图。在模式中插入自定义视图的唯一目的是触发一些自定义代码。自定义代码可以满足您的任何需求。之后,您可以通过从模板中删除特殊视图并重定向回该视图来进行清理。
Another method (which I must blog on soon) is to fake a list creation event. I add an empty view definition with a custom aspx page to the list template. The custom page simply executes some custom functionality on the list, deletes the initialisation view, then redirects to the normal view. It's a little messy, and it will only work if the list is created through the UI, but it works.
Here is a very quick example. You already have your list template. In the schema.xml file, add a new View to the Views element like so:
You may be able to go without the empty elements in there. That was something I was going to test further before blogging on it. But this will get the job done. The important things are:
For the custom page (init.aspx in my example), I just made a copy of ...\12\TEMPLATE\Pages\viewpage.aspx and changed what the page inherits from. You could do this with inline code, but I used a codebehind assembly. So first line of that file becomes:
And then the codebehind:
Basically, we are relying on the SharePoint default behavior to display the default view of a list after creation. A custom view is inserted in the schema with the sole intention of firing off some custom code. The custom code does, well, whatever you want. After this, you clean up by deleting the special view from the template and redirecting back to the view.