Monday, October 28, 2013

Tutorial : E-mail Templates & Custom Placeholders


E-mail templates define the structure and content of marketing e-mails that you send to customers using an e-mail or dialog activity. 
E-mail templates can contain placeholders for content, such as e-Marketing Spots, links, unique promotion codes, and the customer's first and last name. When it is time to deliver the e-mail, the server replaces the placeholders with actual content.


While using the email templates , we may be faced with providing custom placeholders , as per the client requirements.

Below are the steps to do so. For demonstration purposes , we would be introducing the customer's phone number as a custom placeholder attribute.

1. Customize the Management Center Open-laszlo files to include the new custom tag for your new custom attribute.

 File
/LOBTools/WebContent/WEB-INF/src/lzx/commerce/marketing/restricted/widgets/EmailTemplateRichTextEditor.lzx

Step 1: Modify the  open lazlo file to introduce "Customer Phone Number" in the selection dropdown.

1. Locate the text "<mktTextlistitem value="lastName" displayName="${mktMarketingResources['lastName'].string}"/>"

2. Add the below text in the next line
<mktTextlistitem value="phoneNumber" displayName="Customer Phone Number"/>

The completed code will look as follows :

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8Ff5H9oTbsSdRzscBrFDkHzenaRCmpCwCDksfoFTwUbrk5BfvHK1L98ECXJCZut9Wx9jXctZWpOcmTJSgw7D-tCvdFhqQNpmOnjldQQiNNSX0c8gPk5aLKmoEW8_9OQtKEbAjHsmD2piY/s640/Fig1.PNG

Step 2: Modify the  on-click handler to insert the custom tag <e-mail:PhoneNumber /> in the editor when the user selects "Customer Phone Number" and clicks on "Insert"

1. Locate the text "<handler name="onclick">"

2. Add the below text in the function implementation
  else if(selected == "phoneNumber") {
     classroot.insertTextAtSelection("<e-mail:PhoneNumber />");
   }

The completed code will look as follows :

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivXaoXIdGm8HBQcZYJQpRrYxkWWssXzQkbRJQbZKGBCo0TmW6NRdTtBd9je8c8KaDWorzZl5oR5q8etEO1fpbCbkLGQoUjT5GPHCW6qp2Uu_UUodRHzoLeWpzK05aDE8HeZrxJBfDsaFK7/s640/Fig2.PNG
Step 3: Build the Open Lazlo project - LOBTools
Right Click "LOBTools" project and click on "Build OpenLaszlo Project" as show in the figure below. Restart server.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghq53tTS2xvOMoLIDPoJIwks_EBtOoe3eLXiGvy3BxqdPpn6PeeJxy-2f5z01XBkmiijgWa_j561_1zkZmZaWkdGd-QdVwNRoQaS5ewgYqawejv3FcW6APEHTmZZ0Xsoiw9gVLXbTZ8GEe/s320/Fig3.png.

This concludes the Management Center customizations.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6oKV3YEUbVVmU4TIxuwVyrr0vmRRh90x9p_KXb0IebtM06RIe14MrNDZYTph443RHDDW6vClL18T9Da906QSTWOVMSVT-Pb25x9LE_ooFr_o6WJnItV3qqJFmia9EvFEgNI5q6Qyy0XIg/s640/Figure4.PNG  
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqjFp6MaJBKZ04epMEYO0HIB1s2Qhu8Gqz-1D9tKxJGv_dawGEMr1556gt_NxogfZVbt8IHzFaxZxO8x73Q_bCxHNT2Fdn2PhEq_Yv6ikPYPEPf4Pk7SGqrajoTXdFoneFw2vyhCPCI-3K/s640/Fig5.png



2. Introduce a Tag implementation class

1. Create a tag implementation class which would contain the logic to replace the placeholder tag <e-mail:PhoneNumber /> with actual content.

This class should implement the "com.ibm.commerce.emarketing.emailtemplate.tag.Tag" interface. Follow the link to understand the interface methods which need to be implemented.

For the pupose of this tutorial , let the fully qualified name of this class be :

'com.wcshub.commerce.emarketing.emailtemplate.tag.TagPhoneNumber'  

2. Make an database entry in the table TAGCLASS.
To more about this table , follow the Infocenter link.  The sample query is provided below:

 insert into tagclass values ('PhoneNumber',  'com.wcshub.commerce.emarketing.emailtemplate.tag.TagPhoneNumber' ,  'Implementation class for Phone Number Tag' , NULL  );

The tutorial is now complete. Test the customizations.


No comments:

Post a Comment