I'm adding the publication title in config file and from there i want to call that title in the resolved item, but in the below code I'm able to read the Pub ID but it will change across the environment for that reason i want to get the publication title/name.
public class ChildPublicationsOnlyResolver : IResolver
{
private const string ConfigFile= "ChildPublicationsOnlyResolver.config";
/// <summary>
/// Website Structure Publication TCMURI in config file
/// </summary>
**private const string WebsiteStructurePublicationFieldName = "IgnorePublications";
private readonly List<TcmUri> _websiteStructurePublicationUri;**
public ChildPublicationsOnlyResolver()
{
_websiteStructurePublicationUri=GetWebsiteStructurePublicationUri();
} /// For Publish and UnPublish, remove all items from the website structure Publication from the list.
/// Website structure Publication URI is read from the config file.
/// </summary>
/// <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>();
StringBuilder infoMessage = new StringBuilder();
infoMessage.AppendLine(string.Format("Removed the following items from a {0} Transaction to {1}:", instruction.Purpose, context.PublicationTarget.Title));
// check for items from the list of publications to ignore (these do not need to be published or unpublished)
foreach (ResolvedItem resolvedItem in resolvedItems)
{
// mark all items from IgnorePublications for removal
**var publicationUri = resolvedItem.Item.Id.GetContextRepositoryUri(); var publicationTitle = resolvedItem.Session.GetObject(publicationUri).Title;**
if (WebsiteStructurePublicationFieldName.Contains(publicationTitle))
{
itemsToRemove.Add(resolvedItem);
}
}
foreach (ResolvedItem itemToRemove in itemsToRemove)
{
infoMessage.AppendLine(string.Format("{0}: {1} ({2})", itemToRemove.Item.Id.ItemType, itemToRemove.Item.Title, itemToRemove.Item.Id));
resolvedItems.Remove(itemToRemove);
}
if (itemsToRemove.Count > 0)
{
// log info mesage about which items have been removed (optionally this can be logged as a warning to stand out in the logfile)
Logger.Write(infoMessage.ToString(), "ChildPublicationsOnlyResolver", LoggingCategory.General, TraceEventType.Warning);
}
}