July 26, 2017

Localization Best practices for pages and pagemeta

In multilingual websites, localization of Page-Meta is something which is tricky as metadata is either part of structure group if you want to apply for set of pages or part of page.

take the scenario of 10 countries , two language each, so you have 20 websites where you have to localize the pages(50 pages per site) of your website. if you go by flat meta data schema for pages. 

or you create a language master. where you localize the pages for the metadata. 



Some issues:
  • Localization needs to be done in multiple publications for each Language.
  • Translation Manager : Multiple publication needs to be localized for each Language e.g. for French both “Content Translation Fr” and “500 Website Parent French”.
  • Priority conflict between Localized Page in “500 Website Parent French” and “500 Belgium Website English”.
  • Blueprinting Complexity Increases.
Approach we took:

- Keep metadata in Component















- In Metadata schema create a component link for that.













Approach Benefits:
  • Only one Publication needs to be localized i.e. “300 Translation Fr”
  • Translation Manager : Metadata for Page gets localized with Content.
  • Priority conflict resolved. Country Master Website  takes priority as there is no Language Website Master.
  • Blueprinting Complexity is reduced.

Any Cons:

As we were using page types to create page similar pages. As page types do not clone the component links, so every pages started having same component which we added to sample 
page

Solution: in next post.

May 29, 2017

Unpublish Dynamic Component when Page is unpublished

We have a setup where component is dynamic and its also used on Page. But by-design in Tridion if you un-publish a Page which is using a dynamic component, it does not un-publish the component.


We have to fetch the component based on the metadata at various places and attached on page where component was also required on page for following requirements.
  • Author driven Page name
  • Author driven page Url
  • Author driven page metadata.
so following event code was written to handle the scenario.  in our scenario 

 [TcmExtension("UnpublishEventHandler")]  
   public class UnpublishEventHandler : TcmExtension  
   {  
     public UnpublishEventHandler()  
     {  
       EventSystem.Subscribe<Page, UnPublishEventArgs>(UnpublishComponent, EventPhases.TransactionCommitted);  
     }  
     public void UnpublishComponent(Page page, UnPublishEventArgs mUnPublishEventArgs, EventPhases mEventPhases)  
     {  
       var appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);  
       string cts = appConfig.AppSettings.Settings["UnpublishPageComponentTemplates"].Value;  
       IList<ComponentPresentation> cpList = page.ComponentPresentations;  
       List<IdentifiableObject> items = new List<IdentifiableObject>();  
       if (cpList != null)  
       {  
         foreach (ComponentPresentation cp in cpList)  
         {  
           if (cts.ToLowerInvariant().Contains(cp.ComponentTemplate.Title.ToLowerInvariant()))  
                        items.Add(cp.Component);  
         }  
         IEnumerable<IdentifiableObject> itemsenum = items;  
          List<TargetType> targets = new List<TargetType> { };  
          foreach (var pubTarget in mUnPublishEventArgs.Targets)  
          {  
            targets.Add((TargetType)pubTarget);  
          }  
          var transaction = PublishEngine.UnPublish(itemsenum, mUnPublishEventArgs.UnPublishInstruction, targets);  
       }  
     }  
   }