sitecore - 如何在 Sitecore DMS 中触发配置文件?

标签 sitecore sitecore-dms

我正在寻找一种允许访问者选择他们希望在网站上显示的内容的方法。

有没有办法以编程方式触发 Sitecore DMS 中的配置文件?

我看过SDN的相关文档(http://sdn.sitecore.net/Reference/Sitecore 6/DMS Documentation.aspx),但目前还没有找到方法。

编辑:在 Sitecore 支持门户上提出此问题 - 一旦我发现更多信息,将发布答案。

最佳答案

我在我的项目中做过类似的事情。查看此代码示例,如果您有任何问题,请告诉我。此外,请确保您也将配置文件添加到内容项中。对项目集合调用 FilterItemByBehavior,它将根据用户过去的浏览行为过滤它们。

 private static Dictionary<string, List<string>> AnalyticsFilter()
    {
        Dictionary<string, List<string>> filter = new Dictionary<string, List<string>>();

        if (Tracker.CurrentVisit.Profiles.Count() > 0)
        {
            foreach (VisitorDataSet.ProfilesRow row in Tracker.CurrentVisit.Profiles)
            {
                List<string> keys = new List<string>();
                foreach (var key in row.Values)
                {
                    if (key.Value >= ResourceHelper.GetInt(new ID(Resources.Settings.AnalyticsProfileSetMinValGuid)))
                        keys.Add(key.Key);
                }
                filter.Add(row.ProfileName, keys);
            }
        }
        if(ResourceHelper.IsTurnedOn(new ID(Resources.Settings.AnalyticsUserProfileEnableSwitch)))
            filter = ApplyUserProfile(filter);
        return filter;
    }


    public static List<Item> FilterItemByBehavior(List<Item> items, int count)
    {
        try
        {
            var filter = AnalyticsFilter();
            foreach (var profile in filter)
            {
                int counter = ResourceHelper.GetInt(new ID(Resources.Settings.AnalyticsProfileTagsFilterMaxGuid));
                if (items.Count <= count) break;
                foreach (string key in profile.Value)
                {
                    if (items.Count <= count || counter == 0) break;
                    items = items.Where(i => (((MultilistField)i.Fields[profile.Key]).GetItems().ToList().Select(x => x.Name).Contains(key))).ToList();
                    counter--;
                }
            }
            return items.Count <= count ? items : items.Take(count).ToList();
        }
        catch (System.Exception ex)
        {
            Sitecore.Diagnostics.Log.Error(ex.Message, ex, new AnalyticsHelper());
            return items.Count <= count ? items : items.Take(count).ToList();
        }
    }

关于sitecore - 如何在 Sitecore DMS 中触发配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11881011/

相关文章:

c# - 根据营销人员 Web 表单中的下拉选择将电子邮件路由到特定的电子邮件地址

sitecore - 在 Sitecore 8 中禁用分析

azure - Azure 中的 Sitecore DMS

Sitecore Personalize 无法正常工作

xslt - 在xslt中,选择具有id的项目,该值在变量中

Sitecore GeoIP 服务不支持个性化

compression - Sitecore 'getMediaStream' 无法正常工作

sitecore - 每天同一时间运行sitecore计划任务

c# - Sitecore 字段 ID 与字段名称

sitecore - 使用 WFFM 在 Sitecore 参与计划中注册访问者