是否可以在 onet.xml 中分配 webpart id?

发布于 2024-08-02 17:25:13 字数 167 浏览 1 评论 0原文

我制作了一个包含三个区域的页面。在 onet.xml 中,我定义了三个 Web 部件,这些部件将在创建站点时添加到页面中。是否可以为 onet.xml 中的每个 Web 部件分配一个 id,或者我是否需要编写一个连接连接的功能接收器?

我最初的想法是在页面本身上使用,但后来我需要 web 部件的 id。

I've made a page with with three zones. In onet.xml I have defined three webparts which will be added to the page upon site creation. Is it possible to assign an id to each webpart in onet.xml, or do I need to write a feature receiver which hooks up the connections?

My initial thought was to use on the page itself, but then I need the id's of the webparts.

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

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

发布评论

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

评论(2

手心的温暖 2024-08-09 17:25:13
<AllUsersWebPart WebPartZoneID="TopColumnZone" WebPartOrder="1"><![CDATA[
            <webParts>
                <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                    <metaData>
                        <type name="Microsoft.SharePoint.Publishing.WebControls.TableOfContentsWebPart,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                        <importErrorMessage>$Resources:cmscore,WebPartImportError;</importErrorMessage>
                    </metaData>
                    <data>
                        <properties>
                            <property name="Title" type="string">$Resources:cmscore,PublishingLayouts_TOCWebPart_Title;</property>
                            <property name="Description" type="string">$Resources:cmscore,PublishingLayouts_TOCWebPart_Description;</property>
                            <property name="ShowPages" type="bool">True</property>
                            <property name="IncludeContentFromStartingLocation" type="bool">False</property>
                            <property name="ChromeType" type="chrometype">None</property>
                            <property name="ChromeState" type="chromestate">Normal</property>
                            <property name="HelpUrl" type="string">/_layouts/help.aspx</property>
                        </properties>
                    </data>
                </webPart>
            </webParts>]]>
        </AllUsersWebPart>

如果您查看上面的代码片段,所有属性都在 Properties 标记中定义,您是否尝试向其中添加 ID ,我猜它应该可以工作。

<property name="ID" type="string">WebPart1</property>
<AllUsersWebPart WebPartZoneID="TopColumnZone" WebPartOrder="1"><![CDATA[
            <webParts>
                <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                    <metaData>
                        <type name="Microsoft.SharePoint.Publishing.WebControls.TableOfContentsWebPart,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                        <importErrorMessage>$Resources:cmscore,WebPartImportError;</importErrorMessage>
                    </metaData>
                    <data>
                        <properties>
                            <property name="Title" type="string">$Resources:cmscore,PublishingLayouts_TOCWebPart_Title;</property>
                            <property name="Description" type="string">$Resources:cmscore,PublishingLayouts_TOCWebPart_Description;</property>
                            <property name="ShowPages" type="bool">True</property>
                            <property name="IncludeContentFromStartingLocation" type="bool">False</property>
                            <property name="ChromeType" type="chrometype">None</property>
                            <property name="ChromeState" type="chromestate">Normal</property>
                            <property name="HelpUrl" type="string">/_layouts/help.aspx</property>
                        </properties>
                    </data>
                </webPart>
            </webParts>]]>
        </AllUsersWebPart>

If you look at the above snippet all the Property are defined in the Properties tag, have you tried to add a ID to it , My guess is it should work.

<property name="ID" type="string">WebPart1</property>
_失温 2024-08-09 17:25:13

我找到了两个解决方案。一种是将 Web 部件添加到页面布局中,但不在区域中。然后你可以使用 id 将它们连接起来。

但我寻求的解决方案是在我的一个 Web 部件中创建一个“InitConnection”函数,该函数在第一次运行时连接页面上的所有其他 Web 部件。

我认为可以对功能装订执行相同的操作,但我采用的解决方案很简单且代码很少。

I've found two solutions. One is to add the webparts to a page layout, but not in zones. then you can use the id's to hook them up.

But the solution I went for was to create a "InitConnection" function in one of my webparts which hooks up all the other webparts on the page the first time it's run.

I think it would be possible to do the same with feature stapling, but the solution I went for was easy and little code.

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