Showing posts with label Custom Resolver. Show all posts
Showing posts with label Custom Resolver. Show all posts

Monday, January 4, 2016

Tridion Custom Tools Example Projects – Custom Resolver

I noticed many questions on Tridion SE, where new developers face issues with setting up projects for Tridion Custom Tools. So in this series of blog posts I am sharing some code examples and extensions for the same.

To start with, I am explaining to set up the Custom Resolver. I've set up a simple Example Code Project and could be found here , I've also shared the the Visual Studio Extension for it, if anyone wants to install a project template for custom resolver it could be found here.


Setting up the project:


1. Create a library project in Visual studio.

2. Add the following dlls as reference:

  • Tridion.Common
  • Tridion.ContentManager
  • Tridion.ContentManager.Common
  • Tridion.ContentManager.Publishing
3. Create a class say “MyCustomResolver” by extending from interface “IResolver”, which is found in “Tridion.ContentManager.Publishing.Resolving” namespace.

4. Implement the method public void Resolve(IdentifiableObject item, ResolveInstruction instruction, PublishContext context, Tridion.Collections.ISet<ResolvedItem> resolvedItems)

5. Sign the Assembly with a Strong Name.

6. Build and add the assembly to GAC on CMS and Publisher Servers, In case you have a separate publisher server.


Installation Process (To be done on CMS and Publisher Boxes):


1. Copy the assembly “ExampleTridionCustomResolver.dll” in to the server.

2. Add the assembly to the GAC.

3. Open “Tridion.ContentManager.config” file from the path “%TridionInstall% \config”.

4. Locate xml element <add itemType="Tridion.ContentManager.ContentManagement.Component"> inside element <resolving> ---> <mappings>. Since we only want to override resolving behavior for components in this example.

5. Inside the child element <resolvers>, add element <add type=" ExampleTridionCustomResolver.MyCustomResolver" assembly=" ExampleTridionCustomResolver, Version=1.0.0.0, Culture=neutral, PublicKeyToken={PublicKeyToken}" /> as a LAST child.

6. Finally, save and close the Tridion.ContentManager.config file and from your list of Windows Services, restart all Windows services that start with Tridion Content Manager. Also restart IIS and the SDL Tridion Content Manager COM+ application. This applies your changes.

Sunday, November 29, 2015

Custom Resolver – Why it's important to deploy it on both CMS and Publisher Servers ?

Recently, We developed a Custom Resolver which deletes the dependent pages from the package, while publishing a component dynamically. 
The Custom Resolver actually overrides the default OOB resolver, more details could be found here.
  
Basically resolving is a process in which publisher identifies the dependent items, which are supposed to publish with the published item. It is a part of overall publishing process and happens before rendering sub-process. 
Since we are overriding the resolving process, it's obvious to deploy the Custom Resolver on the server where publisher runs. 

In our case, we had a separate publishing server, so we deployed the custom resolver to the publisher server. And it started working as expected by not including the dependent pages while publishing the components.

But then we noticed one issue, On publishing a component, in the publishing dialog on clicking “Show Items to Publish” button the dependent pages were still showing. 


And it was confusing content editors that dependent pages are being published and resolver is not working. Though it was working actually and it's just the dependent pages were listed in the publish dialog.

The issue occurred because the “Show Items to Publish” button uses resolver on CMS server not on Publisher server. And since we didn't deploy our custom resolver to CMS server the default resolver was running there.

So to fix the issue, we needed to deploy our custom resolver on CMS server as well so that it overrides the default behavior of the resolver. 
And once we deployed the custom resolver to CMS server, the issue was resolved.