在我目前正在进行的实施中,我们正在使用类似于第二个解决方案的东西。我将网站主出版物(我们在其中创建所有页面)添加到我们用于所有网站的发布目标中,以便我们可以使用从那里发布到所有子出版物。如果它适合您的模型,我会更喜欢此选项,因为它继续通过子出版物中的本地化让您控制项目。
由于我们不想在网站主出版物上呈现内容(因为这不会发生任何事情,只会浪费我的发布者处理器时间,然后在部署时也浪费代理存储),我们创建了 ChildOnlyPublicationResolver (SDL Tridion 2011)。在此解析器中,我们遍历所有已解决的项目,如果该项目来自网站主出版物,我们将其从列表中删除。
结果是您将看到网站主出版物出现在发布队列中,但由于其中没有要呈现的内容,它几乎会立即设置为成功。因此,它不会占用发布者的任何性能,也不会部署它,但您可以保留子出版物的好处,并且可以轻松地一次性发布它们。
如果有兴趣,这里是解析器代码的示例:
using System.Collections.Generic;
using Tridion.ContentManager;
using Tridion.ContentManager.Publishing;
using Tridion.ContentManager.Publishing.Resolving;
namespace SDL.Example.Resolvers
{
public class ChildOnlyPublicationResolver : IResolver
{
/// <summary>
/// Master Publication TCMURI
/// </summary>
private const string MasterPublicationTcmUri = "tcm:0-2-1";
/// <summary>
/// For publish and unpublish, remove all items from the master publication from the list.
/// </summary>
/// <param name="item">Item to be resolved (e.g. a page, structure group, template)</param>
/// <param name="instruction">Resolve instruction</param>
/// <param name="context">Publish context</param>
/// <param name="resolvedItems">List of items that are currently to be rendered and published (added by previous resolvers in the chain)</param>
public void Resolve(IdentifiableObject item, ResolveInstruction instruction, PublishContext context, Tridion.Collections.ISet<ResolvedItem> resolvedItems)
{
List<ResolvedItem> itemsToRemove = new List<ResolvedItem>();
TcmUri masterPublicationUri = new TcmUri(MasterPublicationTcmUri);
// check for items from master publication (these do not need to be published or unpublished)
foreach (ResolvedItem resolvedItem in resolvedItems)
{
// mark all items from website structure publication for removal
if (resolvedItem.Item.Id.PublicationId == masterPublicationUri.ItemId)
{
itemsToRemove.Add(resolvedItem);
}
}
// remove all items that we need to discard
foreach (ResolvedItem itemToRemove in itemsToRemove)
{
resolvedItems.Remove(itemToRemove);
}
}
}
}