December 19, 2015

Comparison of different DXA version.

DXA new versions are being released with quite a good pace, i think each quarter they are releasing new version. so far 1.01, 1.1 and 1.2 are released. Bart & his team doing very remarkable job in it. when i first time used DXA 1.01 there were numbers of bugs in it, but in each version its improving. its making development very rapid.  I am here trying to summarize what each release of DXA brings to table.



DXA 1.01 (STRI)

DXA 1.1

DXA 1.2

DXA 1.3 (not released yet, may change)

Release Date

Sep 2014

Aug 2015

Nov 2015

 Expected (Jan/Feb 2016)
DD4T version1.311.312.02.0

Tridion Version 

SDL Tridion 2013 SP1

SDL Tridion 2013 SP1 HR1

SDL Tridion 2013
 SP1 HR1

SDL Tridion 2013 SP1 HR1 & SDL WEB 8

.net framework

4.5.1

4.5.1

4.5.1

4.5.2

Official Modules
  • Google Analytics
  • Search
- GA
- Search
- Smart Target
- Media Manager
- GA
- Search
- Smart Target
- Media Manager

Asp.net MVC MVC 5 MVC 5 MVC 5 MVC 5

Changes


  • ·Improved support for creating Modules
  • ·Solutions changes and Refactoring of code
  • Better Performance
  • Improvements in handling Media Items.
  • Page Includes as Region
  • No separate installation of Node js required, its included.
  • Html-design splitted into two files , 1 for fixed grunt modules , 2 for app related css, js etc.
  • Updated Syntax for rendering region and markups


December 13, 2015

Donut caching using Outputcache with DXA

Donut caching is the best way to cache an entire web page except for one or more parts of the web page. unfortunately post asp first version asp.net do not provide any good way to implement it.

I required to implement it in my project as i want all CMS pages to be cached except for the dynamic login and other sections. As DXA 1.2 has single method to process pages in Page Controller, and DxaEntity for component presentation. so if you apply OOTB Asp.net Outputcache attribute to it. it will cache entire page including the dynamic sections.
While searching for solution i come across the DevTrends' library which enables Donut caching Asp.net mvc solutions. i downloaded it from NuGet. using "install-package MvcDonutCaching" but could not use as it is because this library Serialize all the parameters passed in htmlAction method.


MvcHtmlString result = htmlHelper.Action(actionName, controllerName, parameters);


Code Change in Library
but problem with this is, the last parameter contains object of DD4T's ComponentPresentation class. so serialization fails while complaining about "no knowledge of this class". so i had to download the Source code of this library and add the reference of "DD4T.ContentModel" and then provided class in question as known type of Serialiser.

public ActionSettingsSerialiser(){_serialiser = new DataContractSerializer(typeof(ActionSettings), new[] { typeof(RouteValueDictionary),typeof(ComponentPresentation)});}

Code Change in DXA Library
Donut Library provides overloads of all methods in Helper.Action method, it provides a additional Boolean parameter which accepts whether to exclude the view from cache or not.
  • Refer the namespace of the library in Sdl.Web.Mvc.Html.HtmlHelperExtensions
  • Add optional parameter in following method.
    - MvcHtmlString DxaEntities(this HtmlHelper htmlHelper, int containerSize = 0, string excludeCache = null)
  • And following changes in  DxaEntity  
  • public static MvcHtmlString DxaEntity(this HtmlHelper htmlHelper, EntityModel entity, int containerSize = 0, string excludeCache=null)
  • bool excludeFromCache = (mvcData.ViewName.ToLower() == (excludeCache!=null?excludeCache.ToLower():string.Empty)); 
  • MvcHtmlString result = htmlHelper.Action(actionName, controllerName, parameters,excludeFromCache)

so i have added a optional parameter in the DxaEntities and DxaEntity Method, if any of the view is required to be excluded from the parent cache, just provide the name of the view.

It will match the viewName if it matches, then true is passed in the HtmlHelper.Action method and exclude this view from the cache.

Change in PageController or you can override the method.
[DonutOutputCache(CacheProfile = "Cache1Hour")]
        public virtual ActionResult Page(string pageUrl) 
web.config settings.
    <caching>
      <outputCache enableOutputCache="true"/>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="Cache1Hour" duration="0" location="Server" />
        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>

August 08, 2015

Profiling and Personalization using Target Groups in DXA DD4T

Profiling and Personalization aka P&P is very useful feature of Tridion. User's behavior can be tracked and user can be targeted with set of content.

In this post i am going to detail P&P custom characteristics use with DXA and DD4T. We started with SmartTarget evaluation but due to license cost and hardware requirement for Fredhopper caused us to evaluate this Out of the box feature of Tridion to use with DXA.

P&P provides basic but very useful personalization features. 
  1. Tracking Keys
  2. Custom Characteristics
Tracking Keys: Tracking keys are used for Implicit Personalization. Using these  you can can track interest as user visits various content. This functionality works on the tridion Category/keywords. Editor add the "Activate tracking" tbb  in the page template and add the category for tracking in CT's Tracked Category.  Schema should also be added to the component also. publish the page.
On your presentation side custom code has to be written using WAI to track the activities. 

Custom Characteristics:  CC are  used for Explicit Personalization. User information for targeting can be collected using some form e.g. gender, age, city, country. This information can be persisted in the broker db for further use.

Steps to use CC

Page Template Change

Include dd4t tbb "Add Target Groups" on the page template.

Define TargetGroup : 
  • Right click on folder and select  TargetGroup.
  • Set the characteristics as shown below.














  • TargetGroup can only be assigned to component Presentations. Lets do it & Publish the page.









XML: 
After publishing page, DD4T page xml will contain Condition need under Component-presentation node.

<Page>
.
.
 <ComponentPresentation>
.
<Conditions>
        <Condition d5p1:type="CustomerCharacteristicCondition" xmlns:d5p1="http://www.w3.org/2001/XMLSchema-instance">
          <Negate>false</Negate>
          <Name>city</Name>
          <Operator>Contains</Operator>
          <Value xmlns:q3="http://www.w3.org/2001/XMLSchema" d5p1:type="q3:string">Mumbai</Value>
        </Condition>
        <Condition d5p1:type="CustomerCharacteristicCondition" xmlns:d5p1="http://www.w3.org/2001/XMLSchema-instance">
          <Negate>false</Negate>
          <Name>city</Name>
          <Operator>Contains</Operator>
          <Value xmlns:q4="http://www.w3.org/2001/XMLSchema" d5p1:type="q4:string">Delhi</Value>
        </Condition>
      </Conditions>
    </ComponentPresentation>
.
.
</Page>

Presentation server

Here XML is de-serialized to c# object
Note: Current DD4T 1.31 which is part of latest  DXA has bug , because of that XML-with- -conditions-tag de-serialization fails.As this is fixed in DD4T 2.0 so i used some code from 2.0 version and fixed it.

When user access the website where we have WAI module configured
  • Cookie is generated with USER_ID key. 
  • If you have non-login website this USER_ID is generated automatically by WAI
  • You can write custom logic to update the USER_ID with your website user_id
There is no OOTB code to work on Conditions on DXA/DD4T, so you have to write custom code to remove the component presentation where condition fails.

Example user is not from Delhi or Mumbai. then delete that component presentation. 

 var  waiPage= new WAIPage(page.Id, this.HttpContext.ApplicationInstance.Context);
            CustomerCharacteristics cc= new CustomerCharacteristics(waiPage.User);
            var city= customerCharacteristics.GetValue("city");
            if (string.IsNullOrEmpty(city))
            {
                cc.SetValue("country", "Kolkata");//this city may come from your Geolocation module.

                cc.ExecuteUpdate();
            }                                                                       
           foreach(var cp in page)
            {
                foreach(var condition in cp.Conditions)
                {
                    if (condition is CustomerCharacteristicCondition)
                    {
                        
                        var ccCondition= (CustomerCharacteristicCondition)condition;
                        var node = (XmlNode[])ccCondition.Value;
                        string city= node[2].Value;       
                                    }
//now you can remove the component presentation here whereever conditions does not match.

                }
            }

now updated page is processed further via DXA for generation of views


June 30, 2015

DXA aka STRI - My Tiny step in Tridion (SDL Web) Reference implementation.

What is in name? as told by a Great Author and a famous community Builder

STRI - SDL Tridion Reference Implementation: Tridion development is usually considered complex and time consuming, also there is learning curve understanding bits any bytes of it. so few Tridion MVPs came together and developed this MVC based solution to make Tridion development bit easy and fast. STRI provides lots of modules out of the box,  which  are usually required for most of the sites.

In under-hood it uses DD4T as default, but you can extend and create your own custom framework if any and use it instead. so all the template work which usually take more time, which includes DWT/Razor, C# tbbs etc, can be developed in MVC with ease.

DXA - Everything is same just a rename. so new name is Digital Experience Accelerator

Each individual community framework and modules,used in DXA, should be supported by their respective owner or community (wherever applicable.)

Note: You might be thinking its just an DD4T. as i mentioned above  DD4T is just another module in DXA, but yes big module along with other useful modules and features e.g
  1. Google Analytics
  2. Solr Search using SI4T framework
  3. Language Selector
  4. XPM Ready, Yes your site is XPM ready from start, no longer  phase 2 stuff now :)
  5. Navigation and breadcrumbs
  6. Image Resizing
  7. Responsive Design using bootstrap

...Many more...

sample site comes with lots of modules integrated for reference. just install and diggit.

Download DXA/STRI