我希望使用 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 示例项目相同的方法获取当前用户的配置文件并访问自定义属性,则自定义配置文件始终为空。
我的配置中一定遗漏了一些东西。任何建议将不胜感激。