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 

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 

   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()))  
         IEnumerable<IdentifiableObject> itemsenum = items;  
          List<TargetType> targets = new List<TargetType> { };  
          foreach (var pubTarget in mUnPublishEventArgs.Targets)  
          var transaction = PublishEngine.UnPublish(itemsenum, mUnPublishEventArgs.UnPublishInstruction, targets);  

December 19, 2016

Social connect Module for Dxa - Internals - Part 2

Social connect Module was developed using Microsoft's OWIN implementation, which actually make it easy to write code.

Nuget packages

 <package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />  
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Facebook" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />

This is most important file of the module. it plugs the module in mvc lifecycle to ensure user is logged in and prompt whenever required for login.

 [assembly: OwinStartup(typeof(Sdl.Web.Modules.Social.Startup))]  

startup.cs has method ConfigureAuth which has responsibility to Register Social networks and add required claims to be returned by the respective social network.

upto now, no Dxa involvement was required but now will start integrating Dxa step by step.

SocialController :
This controller acts as main interaction of the system. it triggers following as per the Component template of the module

  • Show the Social network options to user
  • Trigger required social network to prompt for credentials
  • Receive token from Social network to validate it & Read the claims and show log out options.
  • Log outs from system

for above 4 set of activities we need different Component templates.

For last three activities three different pages have been created so that only specified activity is triggered as per the need of user. First activity is part of Header page.

If you need to retrieve authentication status or User information following can be used.

  • Request.IsAuthenticated
  • User.Identity.GetUserName()

December 15, 2016

Packaging an SDL DXA Custom Module

SDL has provided good API's to develop an DXA module. I have recently published two modules

  • JwPlayer Module
  • Social Connect/Login Module (updated)
Though creation of module is of medium complexity but packaging of module is also not easy. so i had hard time initially packaging a module. 

Packaging essentially means providing CMS and CD part in one zip file with respective power-shell scripts to automate the installation on CMS(via calling core Service) and deploying the necessary files on the website. 

CM Part- CM part is where building blocks along with required components, content porter package is created. it has three parts

  •  Import Export folder - Where SDL provided Dlls and powershell scripts are kept which helps in importing the module.
  • Content Porter Package -  To Export content porter package
    • Do not select dependencies
    • Select all required component and pages at website publication only, with setting select folder and all children. in this way only small package with required items will be created.
  • Custom Export Power shell script
    • Download some existing DXA module
    • Take script of that
    • and do required modifications
CD Part - 
  • Copy your Area and respective views
  • Copy required dll into Bin folder
  • Use existing power-shell script from some module
  • if you have custom setting like. web.config to update etc. then write the required power-shell script. refer my social login module for that. 
now try above and zip it for delivery.