开发者

Sitecore OMS - best practice for content hierarchy

I am inheriting an existing Sitecore implementation that has large folders of content all using the same template. Some of the folders contain literally hundreds of articles. Different folders should be of interest to different type of Personas. I would like to not have to go article by article setting the Personas and Profile properties for each individual page. Ideally I would like to enter the properties only once for an entire folder of articles. What is the best practice in a case like this?

Should I be creating a different template for each type of article? Or is there a way to inherit these properties from a parent item in the content tree?

Thanks

EDIT

I had a conversation online with John West, CTO of Sitecore USA. Here are his suggestions to approach this problem. I thought of sharing them here since some other people might be interested in solving a similar problem.

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 st开发者_StackOverflow中文版andard 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.

I liked the idea of adding a boolean field to the existing template that controls whether the item is supposed to copy the Profile values from its direct parent and then implement a save handler to do the copy when that field is set to true. So I asked John if there was documentation on how to build such handlers. Here is his kind reply:

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


I think there may be a better way of doing this, using the startTracking pipeline. Check out the Sitecore.Analytics.Pipelines.StartTracking.ProcessItem processor. This is where Sitecore obtains the context item, and logs its profile values to the AnalyticsTracker using a supporting class, TrackingFieldProcessor. You could duplicate this class, and depending on the template of the context item (or a flag on the template), log its parent's profile data as well using the TrackingFieldProcessor.Process(Item) method.

EDIT

This is a little new to me too as far as the Sitecore API goes, but here are more specific steps you should try. You should use IlSpy to look at referenced classes in Sitecore.Analytics.dll.

  1. Create a subclass of Sitecore.Analytics.Pipelines.StartTracking.StartTrackingProcessor
  2. Implement the Process method, using Sitecore.Analytics.Pipelines.StartTracking.ProcessItem as a reference. If Context.Item meets your criteria (e.g. Template GUID), then use the code below to track analytics based on its parent.
  3. Add your class to Sitecore.Analytics.config as the last item in the startTracking pipeline.

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

In case you aren't familiar with using pipelines:

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

(Though this isn't a custom pipeline, you're just tapping into an existing one.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜