gpt4 book ai didi

Sitecore OMS - 内容层次结构的最佳实践

转载 作者:行者123 更新时间:2023-12-04 15:36:58 25 4
gpt4 key购买 nike

我正在继承现有的 Sitecore 实现,该实现具有全部使用相同模板的大型内容文件夹。一些文件夹包含数以百计的文章。不同类型的角色应该对不同的文件夹感兴趣。我不想逐篇为每个页面设置角色和配置文件属性。理想情况下,我只想为整个文章文件夹输入一次属性。在这种情况下,最佳做法是什么?
我应该为每种类型的文章创建不同的模板吗?或者有没有办法从内容树中的父项继承这些属性?
谢谢
编辑
我与 Sitecore USA 的 CTO John West 进行了在线对话。以下是他解决这个问题的建议。我想在这里分享它们,因为其他一些人可能有兴趣解决类似的问题。

I don't know of any existing solution to inherit these values, but there are probably other approaches (maybe similar to language fallback).

If the number of templates is relatively small, I would probably go with the templating approach - turn the existing template into a base template for templates for all of the existing items, and update insert options accordingly. It wouldn't hurt to put these things in folders, but they won't inherit these values that way (you could implement something that would inherit them as mentioned above). One of the benefits here is that you could update those details in standard values, which would apply to all items based on those templates.

Another way would be to implement something like layout and security presets, but for these other values.

Whatever you do, make sure that when the user creates a new item, they can eaily apply these properties, or they get applied automatically.

Another way would be to write a script that updates the existing items, but that doesn't help with future items (unless you do something like a save handler to apply the same values automatically on creation). Maybe copy the values from that parent folder.


我喜欢在现有模板中添加一个 bool 字段的想法,该模板控制项目是否应该从其直接父级复制 Profile 值,然后在该字段设置为 true 时实现保存处理程序来执行复制。所以我问约翰是否有关于如何构建这样的处理程序的文档。这是他亲切的回复:

This explains some of the ways you can tap in to item creation/change to set your values:

http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/11/Intercepting-Item-Updates-with-Sitecore.aspx

I assume you could use an item:saved event handler. I avoid item:created handlers because if my logic goes wrong, I want it to run again on the next save event. In your case, if these fields are empty, you probably want to set the value.

You can use the factory to pass parameters to your event handler to avoid hard-coding. For example, you might pass the database name master (abort the handler if the saved item is in a different database) and a list of the affected template IDs. Then you can more easily add templates to the list in the future.

http://www.sitecore.net/en/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/02/The-Sitecore-ASPNET-CMS-Configuration-Factory.aspx

Here's some information about events:

http://sdn.sitecore.net/Articles/API/Using%20Events.aspx

This includes an example that uses a save handler:

http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/06/Sitecore-Shared-Source-NewsMover-Categorizes-News-by-Date.aspx

最佳答案

我认为使用 startTracking 管道可能有更好的方法来做到这一点。查看 Sitecore.Analytics.Pipelines.StartTracking.ProcessItem 处理器。这是 Sitecore 获取上下文项并使用支持类 TrackingFieldProcessor 将其配置文件值记录到 AnalyticsTracker 的地方。您可以复制此类,并根据上下文项的模板(或模板上的标志),使用 TrackingFieldProcessor.Process(Item) 方法记录其父级的配置文件数据。

编辑

就 Sitecore API 而言,这对我来说也有点新,但您应该尝试以下更具体的步骤。您应该使用 IlSpy查看 Sitecore.Analytics.dll 中引用的类。

  • 创建 Sitecore.Analytics.Pipelines.StartTracking.StartTrackingProcessor 的子类
  • 实现 Process 方法,使用 Sitecore.Analytics.Pipelines.StartTracking.ProcessItem 作为引用。如果 Context.Item 符合您的标准(例如模板 GUID),则使用下面的代码根据其父项跟踪分析。
  • 将您的类添加到 Sitecore.Analytics.config 作为 startTracking 管道中的最后一项。

    TrackingFieldProcessor trackingFieldProcessor = new TrackingFieldProcessor();
    trackingFieldProcessor.Process(item.Parent);

  • 如果您不熟悉使用管道:

    http://adeneys.wordpress.com/2008/08/27/creating-and-running-custom-pipelines-in-sitecore/

    (虽然这不是自定义管道,但您只是在利用现有管道。)

    关于Sitecore OMS - 内容层次结构的最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6019918/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com