2

我希望使用 Sitecore 创建一个产品目录站点,该站点允许用户将产品保存到他们在使用该网站时可以管理的自定义列表中。

这些列表可能包含数百个项目,因此使用标准自定义配置文件属性可能会失控,因此我认为使用外部数据源是最好的方法。

是否有任何示例说明如何实现存储到外部 sql 数据库的自定义配置文件提供程序?有一个更好的方法吗?

更新 对此进行扩展。为了测试,我从这里下载了 SQL 表配置文件提供程序示例:http: //code.msdn.microsoft.com/Using-the-SQL-Table-4c220996 并使用它运行。然后,我在 Sitecore 项目中添加了对此提供程序的引用。在 web.config 我有:

<profile defaultProvider="switcher" enabled="true" inherits="Sitecore.Security.UserProfile" >
        <providers>
            <clear />

           <add name="sql" type="System.Web.Profile.SqlProfileProvider"  connectionStringName="core" applicationName="sitecore" />

           <add name="TableProfileProvider"
                   type="Microsoft.Samples.SqlTableProfileProvider, SQLTableProfileProviderCS"
                   connectionStringName="myProfileConnString" table="aspnet_Profile2"
                   applicationName="/" />

            <add name="switcher" type="Sitecore.Security.SwitchingProfileProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/profile" />
        </providers>
        <properties>
            <clear />
            <add type="System.String" name="SC_UserData" />

        </properties>
    </profile>

在switchingProviders下:

        <profile>
            <provider providerName="TableProfileProvider" storeFullNames="false" wildcard="%" domains="mydomain" />
            <provider providerName="sql" storeFullNames="true" wildcard="%" domains="*" />
        </profile>

在 /Security/Domains.config 中:

<domain name="mydomain" ensureAnonymousUser="false"/>

如果我尝试使用与 SQL Table Profile Provider 示例项目相同的方法获取当前用户的配置文件并访问自定义属性,则自定义配置文件始终为空。

我的配置中一定遗漏了一些东西。任何建议将不胜感激。

4

2 回答 2

4

你会发现这个文档很有趣。它包含有关提供程序系统如何工作的低级详细信息,并就在 Sitecore 的上下文中实施自定义提供程序提供了特别建议。

更新:如果您只想使用外部存储的某些属性扩展配置文件功能,我认为您不应该实现其他类型的提供程序。这些作品非常独立,但我自己没有尝试过。

通常,您要查找的内容在 Sitecore 文档中被称为“部分配置文件功能”。我上面提到的文件包含以下注释:

重要默认 Sitecore CMS 安装不支持在不同存储中拥有不同用户配置文件属性集的选项。您必须安装 Active Directory 模块并进行相应配置才能使用此选项(请参阅 Active Directory 模块文档)。

因此,使其工作的某些功能可能隐藏在 AD 模块的某个位置,而不是默认的 Sitecore CMS 中。我认为您不应该配置AD 模块 - 否则将毫无意义 - 只需安装它。

除了这个 Profile Provider 之外,它仍然有点具体——请仔细查看4.2 Profile Provider Implementation Recommendations部分。

最后,我鼓励您更深入地研究该主题 - 它非常先进,可能需要进行一些调整,但您的场景似乎并非不可能用已经存在的内容来实现。

于 2012-02-21T06:39:09.510 回答
2

如果我理解正确,我相信您可以在web.config此处自定义:

<profile defaultProvider="sql" enabled="true" inherits="Sitecore.Security.UserProfile, Sitecore.Kernel">
  <providers>
    <clear />
    <add name="sql" type="System.Web.Profile.SqlProfileProvider" connectionStringName="core" applicationName="sitecore" />
    <add name="switcher" type="Sitecore.Security.SwitchingProfileProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/profile" />
  </providers>
  ...

如您所见,该提供程序是一个标准的 ASP.NET 配置文件提供程序(在此处参考)——特别是一个SQL 提供程序——因此您应该能够按照任何 .NET 指南进行操作。

于 2012-02-21T03:34:25.570 回答