Dynamic content refers to website content that isn't fixed or static, but changes based on user action. Use dynamic content on your website to display data from third-party services without updating the website every single time.
For example, you can integrate two different applications such as Zoho Sites and Zoho Creator to display dynamic content on your website.
Steps to Insert dynamic content into your website
Click the + icon at the top-left corner of your website builder.
Click App from the dropdown.
Select Dynamic Content from the options.
Drag and drop Dynamic Content to the location where you'd like it to be displayed. Enter Dynamic Content Name.
Click Edit. You will be taken to the Dynamic Content Listing page where you can select the appropriate dynamic content
Click the relevant dynamic content to edit the existing code or write a custom one. You can edit views, functions and sytlsheets.
The four components of dynamic content:
FUNCTIONS
Here's a function named "fetchPartners" that fetches records stored in Zoho Creator:
Explanation:
VIEWS
Every instance of dynamic content has a main view file, and it loads the view available.
View: main
{% partners = functions.execute("fetchPartners") %} <div> <center><h3>Partners</h3></center> </div> <div dc-container="partner-area"> {% for partner in partners %} <div> <h2 style="cursor: pointer" dc-param-id="{{ partner.ID }}" dc-bind-click="true"dc-view="partner" dc-target="partner-area"> {{ partner.name }} </h2> <p>{{ partner.email }}</p> </div> {% endfor %} </div>
Explanation:
Attribute | Description |
dc-container | Defines a container to load a DC view, value should be alphanumeric and unique. |
dc-bind-click | Binds click event for the HTML element, value should be either "true" or a name of callback function. |
dc-view | Defines the DC view name when the HTML element is clicked. Required when dc-bind-click = "true". |
dc-target | Defines the container where the DC view defined in dc-view will be loaded. Value should be one of dc-container. |
dc-param-<param-name-placeholder> | Defines parameters that need to be sent to DC view. There can be multiple use, all such dc-param attributes are sent to DC view. eg. dc-param-pid="123" can be accessed in DC view with request_object.parameters.pid |
View: partner
{% partner_id = request_object.parameters.id %} {% partner_details = functions.execute("fetchPartnerDetails", partner_id) %} <div><h2>{{ partner_details.name }}</h2> <p>{{ partner_details.phone }}</p> <img alt="{{ partner_details.name }}" src="{{ partner_details.image }}" /> <div style="cursor: pointer" dc-view="main" dc-target="partner-area"> back </div> </div>
Explanation:
DC View function
{% records = functions.execute("fetchPartners") %}
Example:
{% records = functions.execute("fetchPartners",param1,param2, ..) %}
Below are the objects and functions available in a dynamic content view.
Property | Description |
display_name | Name of the logged-in user |
email_address | Email address of the logged-in user |
groups | Display name list of portal group the user belong |
Example:
{% if user %} {"display_name":"{{ user.display_name }}","email_address":"{{ user.email_address }}"}. {% endif %}
Property | Description |
domain_name | Domain part of request |
uri | URI path of the request |
parameters | Collection of parameters |
headers | Collection of request headers |
cookies | Collection of cookies |
Example:
{% partner_id = request_object.parameters.id %}
This is used to invoke functions in dynamic content.
Example:
{% assign variable_name = functions.execute("dc_function_name", param1, param2, ...)%}.
{% response_object.setStatus(status_code) %}
{% response_object.setCookies(cookie_name, cookie_value, path, max_age) %}
JAVASCRIPT
The following are the API methods available for JavaScript.
Method | Description |
$DX.get | Sends
HTTP GET
request to
DC view. Request Object
as an
argument, please
refer table below. |
$DX.post | Sends
HTTP POST
request to
DC view.
Request
Object as
an argument, please
refer table below. |
Property | Description |
url | URL of the view |
params | Parameters to be sent to view as JSON object |
handler | On successful response, this callback function will be called with XMLHttpRequest as "this" reference. |
headers | Collection of request headers |
args | Arguments to be sent to handler as JSON object |
Overriding the "init" function
Here is an example of main.js overriding the "init" function and handling view loading itself
define( function() { function showPartner(options){ $DX.get({ url: "/dcapp/" + options.dc_name + "/partner", params : options.params, handler: function (){ options.target.innerHTML = this.responseText } } ); } function init(context, params){ var dc_name = context.getAttribute('data-dc-name'); //the attribute data-dc-name of the root DC element has the DC name var dc_home_page = context.getAttribute('data-home-page') || 'main'; //the attribute data-dc-name has the default view name $DX.get({ url: "/dcapp/" + dc_name + "/" + dc_home_page ,// No I18N handler: function (){ context.innerHTML = this.responseText } } ); } return { showPartner : showPartner, init : init } })
$DX.get({
url: "/dcapp/" + <dc_name> + "/function/" + <dc_function_name >,
handler: function (){
//code to handle function get
}
Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.
If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.
You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.