Varying content and presentation by host name in Sitecore 6.4

喜你入骨 提交于 2019-12-24 02:09:56

问题


Scenario: A section of the content tree is the home item for a site that runs under two host names (www.site1.com and www.site2.com

The purpose of the two host names is to differentiate between two target countries that are served with the same content, and the same organisation (marketing department, web editor etc.)

The content is, of course, identical across the two host names.

Except....

In a couple of places we need some small differences. A contact email, for instance, or a legal notice (these are both just Sitecore content). In other places we may wish to be able to change a presentation component for an item based on which host context it's in. We may wish to do this across all items from a specific template.

To complicate matters, the site is already cloned from another site (www.siteA.com), which is the source of several clones (some translated) for different countries. This is to enable us to push new items/content changes/features to our subsidiary companies. So all templates and presentation components are already shared across lots of host contexts and lots of portions of the content tree.

Is there any Sitecore functionality that would make this possible/simple - or do we need to code context testing into our presentation components (presumably alongside some configuration items within Sitecore to avoid hardcoding values)?


回答1:


Great question. This is a long-shot, but it may work:

Why don't you create a new device for Site2 and in the cases where Site2 presentation data needs to change, configure the presentation settings for the Site2 device. If not, don't set them and the Default device will render the content. The hard part here will be configuring how the device will resolve. Maybe you can create a custom device resolver in the <httpRequestBegin> pipeline:

<processor type="Sitecore.Pipelines.HttpRequest.BeginDiagnostics, Sitecore.Kernel"/>
<!--<processor type="Sitecore.Pipelines.HttpRequest.DeviceResolver, Sitecore.Kernel"/>-->
<processor type="YourProject.Pipelines.HttpRequest.DeviceResolver, YourProject"/>
<processor type="Sitecore.Pipelines.HttpRequest.LanguageResolver, Sitecore.Kernel"/>

In your processor you can look at the host to determine which to use.

You can also define the Site2 device on a new <site ... /> node as Paul mentions below. Something like this:

<site name="site1" hostName="site1.com" rootPath="/sitecore/content" startItem="/home" ... />
<site name="site2" hostName="site1.com" device="Site2" rootPath="/sitecore/content" startItem="/home" ... />

Both Site1 and Site2 point to the same parts of the tree, they just use different devices.



来源:https://stackoverflow.com/questions/8836682/varying-content-and-presentation-by-host-name-in-sitecore-6-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!