Preview Multiscreen Template

Overview

Using the Duda API you can pull a list of available templates and display them on the page. Then you can allow users to preview what the template looks like with the preview URL of the template. 

Target Audience

Anyone wanting to display a list of available templates for their users to preview and see. Great for a gallery page or getting started page.

Essentials before getting started

Requested API access and have been approved. Have your API user and password keys ready. Also have a web server with PHP installed to install the template preview. 

Steps to implement

Download full implementation code (attached to this article)

1) Get all templates and display in table layout

To get all available templates, we call the GET templates URI. This returns all available templates in JSON representation. Also make sure you have the cURL php module/library installed. 

API URL: https://api.dudamobile.com/api/sites...reen/templates

URL Parameters: none

Success response code: [http_code] => 200

PHP Code example: (replace {parameter} with actual value)

<?php 
//Set API user and password
$API_USER = 'xxxxxxxxxx';
$API_PASS = 'yyyyyyyyyy';
//Set parameters to make cURL call to Duda
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, 'https://api.dudamobile.com/api/sites/multiscreen/templates');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $API_USER.':'.$API_PASS);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
//execute cURL call and get template data
$output = curl_exec($ch);
//check for errors in cURL
if(curl_errno($ch)) {
die('Curl error: ' . curl_error($ch));
}
$output = json_decode($output);
//Loop through all templates and display all the available templates in a table
echo '<table><thead><tr><th>Template Name</th><th>Template Image</th><th>Template Id</th></tr></thead>';
foreach($output as $template) {
echo '<tr>';
echo '<td>' . $template->template_name . '</td>';
echo '<td><a href='.$template->preview_url.' target="_blank"><img src=' . $template->thumbnail_url. '></a>' . '</td>';
echo '<td>' . $template->template_id . '</td>';
echo '</tr>';
}
echo '</table>';
?>

This will display all templates to chose from. You can then click on each image and see a live preview of the template. The page should output something similar to this:

 

You can view an example of this white labeled template page here: http://templates.multiscreensite.com/

×

Priority Phone Support

English phone support is available 18 hours a day,
Monday through Friday, 3am to 9pm (EST).

United States +1 866-776-1550 3am to 9pm (Eastern)
United Kingdom +44 (0)800-011-9071 8am to 2am (London)
France +33 (0)9-75-18-84-74 9am to 3am (Paris)
Israel +972 (0)3-720-8922 10am to 4am (Jerusalem)
Australia +61 (0)2-8880-9166 7pm to 1pm (Sydney)
To schedule a call in French, Portuguese, Hebrew or Russian, please email us at prioritysupport@dudamobile.com
×

Please Log in as a DudaPro

Priority Phone Support is available exclusively to DudaPros. Log in to your DudaPro account now to see our international support numbers.

Log In
Not a DudaPro? Start a free trial now!