To create and validate Publisher Presentation Templates, use the IPresentationTemplateManager interface in the IDK.
After you have created the markup for a Presentation Template, you must create and store it using IPresentationTemplateManager so it can be used to publish content items. If published content items should not be included in the search index, set the searchable flag on the Presentation Template object to false.
Java
... StringBuffer templateBuffer = new StringBuffer(""); templateBuffer.append(" <table border='1' \n") .append("<tr> <td> <b> Incident ID </b> </td> <td> <pcs:value expr='Incident_ID'></pcs:value> </td> </tr>\n") .append("<tr> <td> <b>Created By </b> </td> <td> <pcs:value expr='createdBy'></pcs:value> on <pcs:value expr='created' format='MMMM d, yyyy'> </pcs:value> </td> </tr>\n") .append("<tr> <td> <b>Resolved </b> </td> <td> <pcs:value expr='Resolved'></pcs:value> </td> </tr>\n") .append("<tr> <td> <b>Severity </b> </td> <td> <pcs:value expr='Severity'> </pcs:value> </td> </tr>\n") .append("<tr> <td> <b>Date Opened </b></td><td> <pcs:value expr='Date_Opened' format='MM, dd, yyyy'></pcs:value></td> </tr>\n") .append("<tr> <td> <b>Customer Name </b> </td> <td> <pcs:value expr='Customer_Name'></pcs:value> </td> </tr>\n") .append("<tr> <td> <b>Customer Information </b> </td> <td> <pcs:value expr='Customer_Information.name'></pcs:value></td></tr>\n") .append("<tr> <td> <b>Product </b> </td> <td> <pcs:value expr='Product'></pcs:value></td> </tr>\n") .append(" <tr> <td> <b>Incident Description </b> </td> <td> <pcs:value expr='Incident_Description'></pcs:value> </td> </tr>\n") .append("<tr> <td> <b>Log File </b> </td> <td> <pcs:value expr='Log_File.name'></pcs:value></td> </tr> \n") .append(" <tr> <td> <b>Screen Shot </b> </td><td> <pcs:value expr='Screen_Shot.name'></pcs:value> </td> </tr> \n") .append(" </table> // Create the Presentation Template. presentationTemplate = ptManager.createPresentationTemplate(dataEntryTemplate.getContainingFolder(), "Customer Support Incident Presentation Template", templateBuffer.toString()); // Store the Presentation Template. presentationTemplate.store(); // Validate the template text before using it to publish // content items. String[] errorsInText = ptManager.validateTemplateText(pt, pt.getTemplateText()); if(errorsInText.length != 0) { System.out.println("PCS validation returned the following errors"); for(int i = 0; i < errorsInText.length; i++) { System.out.println("error[" + i + "]: " + errorsInText[i]); } } } ...
.NET (C#)
... StringBuilder templateBuffer = new StringBuilder(); templateBuffer.Append("<table border='1'>\n") .Append("<tr><td><b>Incident ID</b></td><td><pcs:value expr='Incident_ID'></pcs:value></td></tr>\n") .Append("<tr><td><b>Created By</b></td><td><pcs:value expr='createdBy'></pcs:value> on <pcs:value expr='created' format='MMMM, dd, yyyy'></pcs:value></td></tr>\n") .Append("<tr><td><b>Resolved</b></td><td><pcs:value expr='Resolved'></pcs:value></td></tr>\n") .Append("<tr><td><b>Severity</b></td><td><pcs:value expr='Severity'></pcs:value></td></tr>\n") .Append("<tr><td><b>Date Opened</b></td><td><pcs:value expr='Date_Opened' format='MM, dd, yyyy'></pcs:value></td></tr>\n") .Append("<tr><td><b>Customer Name</b></td><td><pcs:value expr='Customer_Name'></pcs:value></td></tr>\n") .Append("<tr><td><b>Customer Information</b></td><td><pcs:value expr='Customer_Information.name'></pcs:value></td></tr>\n") .Append("<tr><td><b>Product</b></td><td><pcs:value expr='Product'></pcs:value></td></tr>\n") .Append("<tr><td><b>Incident Description</b></td><td><pcs:value expr='Incident_Description'></pcs:value></td></tr>\n") .Append("<tr><td><b>Log File</b></td><td><pcs:value expr='Log_File.name'></pcs:value></td></tr>\n") .Append("<tr><td><b>Screen Shot</b></td><td><pcs:value expr='Screen_Shot.name'></pcs:value></td></tr>\n") .Append("</table>\n"); // Create the Presentation Template. IPresentationTemplate presentationTemplate = ptManager.CreatePresentationTemplate(dataEntryTemplate.GetContainingFolder(), "Customer Support Incident Presentation Template", templateBuffer.ToString()); // Store the Presentation Template. presentationTemplate.Store(); // Validate the template text before using it to publish content items. String[] errorsInText = ptManager.ValidateTemplateText(pt, pt.TemplateText); if(errorsInText.Length != 0) { Console.WriteLine("PCS validation returned the following errors"); for(int i = 0; i < errorsInText.Length; i++) { Console.WriteLine("error[" + i + "]: " + errorsInText[i]); } } ...
.NET (VB)
... Dim templateBuffer As StringBuilder = New StringBuilder templateBuffer.Append("<table border='1'>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Incident ID</b></td><td><pcs:value expr='Incident_ID'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Created By</b></td><td><pcs:value expr='createdBy'></pcs:value> on <pcs:value expr='created' format='MMMM d, yyyy'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Resolved</b></td><td><pcs:value expr='Resolved'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Severity</b></td><td><pcs:value expr='Severity'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Date Opened</b></td><td><pcs:value expr='Date_Opened' format='MMMM d, yyyy'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Customer Name</b></td><td><pcs:value expr='Customer_Name'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Customer Information</b></td><td><pcs:value expr='Customer_Information.name'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Product</b></td><td><pcs:value expr='Product'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Incident Description</b></td><td><pcs:value expr='Incident_Description'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Log File</b></td><td><pcs:value expr='Log_File.name'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("<tr><td><b>Screen Shot</b></td><td><pcs:value expr='Screen_Shot.name'></pcs:value></td></tr>" + System.Environment.NewLine) templateBuffer.Append("</table>" + System.Environment.NewLine) ' Create the Presentation Template with the template text. Dim presentationTemplate As IPresentationTemplate = ptManager.CreatePresentationTemplate(dataEntryTemplate.GetContainingFolder(), "Customer Support Incident Presentation Template", templateBuffer.ToString()) ' Store the Presentation Template. presentationTemplate.Store() ... ' Validate the template text before using it to publish items Dim errorsInText() As String = ptManager.ValidateTemplateText(presentationTemplate, presentationTemplate.TemplateText) If errorsInText.Length <> 0 Then Console.WriteLine("Validate Template Text returned the following errors") Dim i As Integer For i = 0 To errorsInText.Length - 1 Console.WriteLine("error[" & i & "]: " & errorsInText(i)) Next End If ...