Hi folks,
We're back with another tip on how to use Zoho Markup Language (ZML) to create interactive pages in Zoho Creator. You can use ZML snippets to add various kinds of components to your pages and structure them in meaningful ways. That's not all, though—using ZML you can ensure your application is automatically compatible with all kinds of devices without any inconsistencies.
We often get questions from users about how to invoke Deluge scripts within ZML code. Here's a simple use case for adding images to your pages:
Step 1
First, we need to create a function that will help us retrieve the image stored in our application. All we need to do is fetch the RECORD ID of the record that contains the image, generate a download URL of the image, and use it in the ZML snippet.
- string getImage(int id)
- {
- fet = images[ID == id];
- var = fet.Image.getSuffix("downqual = \"").getSuffix("image/").getPrefix("\"");
- img = "https://creatorexport.zoho.com/file/<app_owner>/<app_name>/<report_linkname>/" + fet.ID + "/<image_field_linkname>/image-download?filepath=/" + var;
- return img;
- }
Step 2
Next, you can go to the Page Builder, drag and drop the ZML panel, and invoke the above function (getImage) where you'll pass the ID to the function to retrieve the URL of the image.
- <%
- {
- x = thisapp.getImage(id); //page param with ID is "id"
- %>
- <panel>
- <pr height='fill' width='fill'>
- <pc width='100%' bgColor='#FFFFFF' padding='20px' hAlign='center' vAlign='middle'>
- <pr height='auto' width='auto'>
- <pc>
- <pr>
- <pc>
- <image color='#FFFFFF' bgColor='#0ABB51' width='1000px' height='1250px' imageType='weburl' value='<%=x%>' /> </pc>
- </pr>
- <pr>
- <pc>
- <text type='Text' value='120' size='8' color='#0ABB51' bold='true' marginTop='3px' textAlign='center'> </text>
- </pc>
- </pr>
- <pr>
- <pc>
- <text type='Text' value='Open tickets today' size='3' color='#333333' marginTop='3px' textAlign='center'> </text>
- </pc>
- </pr>
- </pc>
- </pr>
- </pc>
- </pr>
- </panel>
- <%
- }
- %>
If you'd like to learn more about ZML, check our ZML guide that covers all the basics for you.
We hope this post was useful! If you have any questions, feel free to ask in the comments below, and we'll be happy to address them soon!
See you all next time, with even more interesting Creator tips!