Get Started
Tailor-Made ItinerariesTour & Cruise ItinerariesFIT Package ItinerariesRole Guides
Kaptio AdminSupplier ContractingProduct Design/BuildProduct ContentTraining ManagerData ExpertsDevelopersKaptio Platform Architecture
Architecture OverviewDevelopment GuidelinesFunctional DecompositionPlatform FAQNew to Salesforce?Security & ComplianceManage your EnvironmentsData Import & ExportGlobal Platform Setup
Getting Started with Core ConfigurationManage Global SettingsConfigure ChannelsManaging Users, Roles & AccessUnderstanding Your Sample DataPIM: Supplier Contracting
Managing SuppliersSetup LocationsManaging ServicesConfigure PricesBulk Import Service DataManage InventoryPromotion & Discount SetupPIM: Tour & Package Design
Getting Started with PackagesUnderstanding Departure TypesManage Package PricingSetup Package ContentConfigure Package DefaultingCRM Module
Customizing Kaptio TravelManage Account Record TypesSetup Trip & Itinerary WorkflowManage Salesforce FeaturesCONNECT: Land & Air Connectivity
Getting Started with ConnectivityPNR Import Setup & UsageIntegrating Amadeus Hotel Connectivity Setup & UsageDOCS Module
Getting Started: ContentManaging Content & MediaSetup Document StagesSetup TemplatesBuilding Custom Content ComponentsBulk Import Content DataUsing the Document Starter KitUsing the ATOL Certificate Starter KitPersonalizing DocumentsGenerating DocumentsCustomer Access to DocumentsEmail Setup & UsageAdvanced Sample Email TemplateCRS: Training Guides
Getting Started: TrainingTraining Reservation TeamsTraining Finance TeamsPAY: Payment Gateway Integrations
Getting Started: PaymentsImplementing Braintree/PayPalIntegrating Your Own GatewayData Migration
Guide to Booking MigrationPeripheral Integration Guides
Accounting IntegrationData Warehouse IntegrationWebsite IntegrationIn this guide, we will walk you through the process of building custom content components for our document templates.
How to Create Custom Content Components
Custom content components provide you with more flexibility when designing your document templates. Learn how to setup these components here.
Code Sample & Step-by-step Guide
Step 1: Determine the Component's Purpose and Functionality
Before you start building a custom content component, it's important to determine its purpose and functionality. What information or data should it display? What actions should it enable? What kind of visual design should it have? Answering these questions will help you create a component that is both useful and visually appealing.
Step 2: Create the Visualforce Page
The first step in building a custom content component is creating the Visualforce page that will display your component. This page should contain the HTML and CSS needed to render your component's visual design, as well as the Apex code that will retrieve and manipulate the data needed to display your component's content.
Step 3: Create the Apex Controller
Next, you'll need to create an Apex controller that will handle the logic needed to retrieve and manipulate data for your component. This controller should implement the KaptioTravel.IComponentHandler interface and define the getBody() and isEmpty() methods.
Step 4: Test Your Component
Once you've created your Visualforce page and Apex controller, it's time to test your component. You can do this by creating a new document template in Kaptio and adding your component to it. Make sure to test your component thoroughly and fix any bugs or issues you encounter.
Step 5: Add Your Component to a Document Template
Once you've tested and refined your component, it's time to add it to a document template. To do this, simply edit the template and drag your component into the desired location. Make sure to save your changes and test your template to ensure that your component is working as intended.
Conclusion
Building custom content components can be a challenging but rewarding process. By following the steps outlined in this guide, you'll be able to create components that are both useful and visually appealing, and that help to enhance the overall quality of our document templates. Good luck!
Custom content components provide you with more flexibility when designing your document templates. Learn how to create these components here.
Code Sample
The following is an example ofa simple custom component that shows payment information using information from the Itinerary.
Please note:Β The context of custom content component is always the Itinerary. You cannot determine which stage type of the document they are within.
- For any display logic dependent on stage type, we recommend that the main document layout contains a class on the body tag that contains the name or type of the stage and target via css.
- For logic reliant on Stage Type we recommend creating a base component for the most common use case and then an additional component for each stage needed, with itβs own extention class that uses the base comoponent for all logic but overrides the stage type for itβs queries.
Apex Class
/**
* @author Vadim
* @date 2016/08/01
* @description Sample class for a custom content components
*/
global without sharing class KTD_CustomContentController implements KaptioTravel.IComponentHandler {
Β Β Β @description A KaptioTravel__Itinerary__c record
Β Β Β Β public KaptioTravel__Itinerary__c itinerary { get; private set; }
Β Β @description Id of context Itinerary. Used to populate the itinerary variable.
Β Β Β private Id itineraryId { get; set; }
Β Β Β Β global KTD_CustomContentController() {
Β Β Β Β Β if(ApexPages.currentPage() != null){
Β Β Β Β Β Β Β this.itineraryId = ApexPages.currentPage().getParameters().get('id');
Β Β Β Β Β Β Β if(Schema.KaptioTravel__Itinerary__c.SObjectType == this.itineraryId.getSobjectType()) {
Β Β Β Β Β Β Β Β Β init(this.itineraryId);
Β Β Β Β Β Β Β }
Β Β Β Β Β }
Β Β Β }
Β Β Β public void init(Id p_id) {
Β Β Β Β Β try {
Β Β Β Β Β Β Β this.itineraryId = p_id;
Β Β Β Β Β Β Β this.itinerary = [
Β Β Β Β Β Β Β Β Β SELECT Id, Name, CurrencyIsoCode, KaptioTravel__Name_on_booking__c, KaptioTravel__VersionNumber__c, Owner.Name, KaptioTravel__Group_Size__c,
Β Β Β Β Β Β Β Β Β KaptioTravel__Amount_Per_Person__c, KaptioTravel__Itinerary_Amount__c, KaptioTravel__Transaction_Amount__c, KaptioTravel__Outstanding__c,
Β Β Β Β Β Β Β Β Β KaptioTravel__FinalPaymentExpectedDate__c, KaptioTravel__BookingNumber__c, KaptioTravel__Channel__r.KaptioTravel__Brand__r.Name,
Β Β Β Β Β Β Β Β Β KaptioTravel__Channel__r.KaptioTravel__ChannelCode__c, KaptioTravel__Primary_Contact__r.Account.BillingCountry,
Β Β Β Β Β Β Β Β Β KaptioTravel__Primary_Contact__r.Account.BillingState, KaptioTravel__Primary_Contact__r.Account.BillingCity,
Β Β Β Β Β Β Β Β Β KaptioTravel__Primary_Contact__r.Account.BillingPostalCode, KaptioTravel__Primary_Contact__r.Account.BillingStreet,
Β Β Β Β Β Β Β Β Β KaptioTravel__Primary_Contact__r.Account.BillingAddress, KaptioTravel__ResellerCommissionTotal__c, KaptioTravel__ResellerCommissionTaxTotal__c,
Β Β Β Β Β Β Β Β Β FROM KaptioTravel__Itinerary__c
Β Β Β Β Β Β Β Β Β WHERE Id = :this.itineraryId
Β Β Β Β Β Β Β ];
Β Β Β Β Β } catch (Exception e) {
Β Β Β Β Β Β Β Β System.debug('KTD_CustomContentController ERROR: ' + e.getMessage() + '; Stack Trace: ' + e.getStackTraceString());
Β Β Β Β Β }
Β Β Β }
Β Β Β /**
Β Β Β * @description Required function for the IComponentHandler interface. Defines the VF page used as output for the component. Defined here to allow the content engine to create a html string from the components output
Β Β Β * @return String HTML output generated from the VF page and data from this controller
Β Β Β **/
Β Β Β public String getBody() {
Β Β Β Β Β PageReference pref = Page.KTD_CustomComponent;
Β Β Β Β Β pref.getParameters().put('id', this.itineraryId);
Β Β Β Β Β Blob content = System.Test.isRunningTest() ? Blob.valueOf('Test') : pref.getContent();
Β Β Β Β Β return content.toString();
Β Β Β }
Β Β /**
Β Β Β * @description Required function for theΒ IComponentHandler interface. If returns true, then the component will not render.
Β Β Β * @return Boolean
Β Β Β **/
Β Β Β public Boolean isEmpty(){
Β Β Β Β Β return false;
Β Β Β }
}
Visualforce page
<apex:page showHeader="false" sidebar="false" standardStylesheets="false" lightningStylesheets="false" docType="html-5.0"
Β Β Β controller="KTD_CustomContentController " id="KTD_CustomContent">
Β Β Β <div class="comonent-content">
Β Β Β Β Β <div class="info-section">
Β Β Β Β Β Β Β <div class="balance-info">
Β Β Β Β Β Β Β Β Β <div class="column-item">
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-label">Total:</div>
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-desc">USD
Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:outputText value="{0,number,###,###,##0.00}">
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:param value="{!itinerary.KaptioTravel__Itinerary_Amount__c}" />
Β Β Β Β Β Β Β Β Β Β Β Β Β </apex:outPutText>
Β Β Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β Β <div class="column-item b2b-commission">
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-label">Commission:</div>
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-desc">USD
Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:outputText value="{0,number,###,###,##0.00}">
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:param value="{!itinerary.KaptioTravel__ResellerCommissionTotal__c}" />
Β Β Β Β Β Β Β Β Β Β Β Β Β </apex:outPutText>
Β Β Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β Β <div class="column-item b2b-commission">
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-label">Reseller Commission Tax:</div>
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-desc">USD
Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:outputText value="{0,number,###,###,##0.00}">
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:param value="{!itinerary.KaptioTravel__ResellerCommissionTaxTotal__c}" />
Β Β Β Β Β Β Β Β Β Β Β Β Β </apex:outPutText>
Β Β Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β Β <!-- -->
Β Β Β Β Β Β Β Β Β <div class="column-item">
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-label">Payment Received:</div>
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-desc">USD
Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:outputText value="{0,number,###,###,##0.00}">
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:param value="{!itinerary.KaptioTravel__Transaction_Amount__c}" />
Β Β Β Β Β Β Β Β Β Β Β Β Β </apex:outPutText>
Β Β Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β <div class="column-item">
Β Β Β Β Β Β Β Β Β Β <div class="column-item-label">Outstanding Balance:</div>
Β Β Β Β Β Β Β Β Β Β <div class="column-item-desc">USD
Β Β Β Β Β Β Β Β Β Β Β Β <apex:outputText value="{0,number,###,###,##0.00}">
Β Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:param value="{!itinerary.KaptioTravel__Outstanding__c}" />
Β Β Β Β Β Β Β Β Β Β Β Β </apex:outputText>
Β Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β <div class="column-item">
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-label">Outstanding Balance due date:</div>
Β Β Β Β Β Β Β Β Β Β Β <div class="column-item-desc">
Β Β Β Β Β Β Β Β Β Β Β Β Β <b>
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:outputText value="{0,date, d MMMM YYYY}">
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β <apex:param value="{!itinerary.KaptioTravel__FinalPaymentExpectedDate__c}" />
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β </apex:outputText>
Β Β Β Β Β Β Β Β Β Β Β Β Β </b>
Β Β Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β Β Β </div>
Β Β Β Β Β Β Β </div>
Β Β Β Β Β </div>
Β Β Β </div>
</apex:page>
- How to Create Custom Content Components
- Code Sample & Step-by-step Guide
- Step 1: Determine the Component's Purpose and Functionality
- Step 2: Create the Visualforce Page
- Step 3: Create the Apex Controller
- Step 4: Test Your Component
- Step 5: Add Your Component to a Document Template
- Conclusion
- Code Sample
- Apex Class
- Visualforce page