Requirement
Display a card layout with each card containing mobile details like an
image,
company,
model, and
features. Any third party languages can also be used, provided the
required dependencies like
packages,
CDN URLs etc. are included. Users can click on a card to purchase the selected phone.
Use Case
A mobile store wishes to enable online purchase of its products. The
Widgets feature is used to create a card layout with the required customization to display its products.
Steps to follow
2. Run the following commands to confirm that the installation is successful. The commands return the version of the package.
Note: When entering commands, there is no need to enter the dollar sign ($) explicitly, it would already be present by default. Commands can be run in Terminal for Mac OS and in Command Prompt for Windows.
Note:
You will be prompted to enter the system password. When typing in the password, the characters won't be visible.
- sudo npm install -g zoho-extension-toolkit
4. Run the following command to confirm that the installation was successful. It returns the version of the package.
5. Now create a project using the following command
Note: Use the following command in the event of permission issues:
sudo zet init
6. Select Zoho Creator.
7. Specify a project name and hit Enter.
Note:
The project is basically a folder which is used to store files that are required to render the widget. The project name can contain only alphanumeric and underscore characters.
8. Type cd <project/folder_name> and hit Enter to navigate to the project directory.
9. Run the following command.
Note: This will run the HTTP server in your local machine in port number 5000. The port should not be occupied with any other process before starting the server. A relevant note may appear as a result of the above command.
10. To verify if the server has started successfully, navigate to widget.html file and open it in a browser. The widget.html file will be present in the folder (project) created earlier.
Note:
- By default, the widget.html file will be present in the App folder.
- You can also access the widget.html file by following the below steps:
- Open the local host URL (https://127.0.0.1:5000) in a new tab and authorize the connection by clicking Advanced->Proceed to 127.0.0.1.
- Append /app/widget.html to the local host URL i.e., https://127.0.0.1:5000/app/widget.html
You should see the following screen:
11. Enter your code in the
widget.html file. Any third party app, for example Sublime, VS Code, Eclipse, etc., can be used to add or modify code in the html file. The
widget.html file contains the structure, design, and components of the Widget. To use the Zoho Creator APIs in the widget, you can use the API helpers provided in the
JS SDK Library.
You can use the attachment provided at the end of this tutorial to build the application. Copy the contents from the attached widget.html file and paste it into the widget.html file created on your machine. Copy and paste the CSS and JS files into the app folder of your project (parent folder). Each file has a specific use. For example, the css file contains code related to the design of the cards, and the JS file contains the code to define the elements in the card.
Note: In the JS file (Widgets -> App -> Assets -> JS), search for creatorapp.zoho.com/<app_owner>/, and replace the placeholders with the actual app owner name and the application link name. Similarly, ensure that the report names are mentioned correctly.
The xls report and images will be later used to import data into the app (Step 14).
12. Ensure you are still in the project directory and run the following command in the terminal.
Note: The previous command will result in exiting the project directory. You have to navigate back to the project directory and run the following command.
13. Next, run the following command:
A zip file of the application will be created in the dist folder of your project directory.
14. Create two forms with the following details:
Form | Form Link Name | Field Type | Field Name | Field Link Name |
Add Mobile | Add_Mobile | Single Line | Mobile Name | Mobile_Name |
Single Line | Manufacturer | Manufacturer |
Drop Down | Storage (with options 16 gb and 32 gb) | Storage |
Drop Down | OS (with options iOS, Android, Windows) | OS |
Number | Camera | Camera |
Multi Line | Description | Description |
Currency | Price | Price |
Image | Small Image | Small_Image |
Image | Large Image | Large_Image |
Order | Order | Single Line | Selected Model | Selected_Model |
Name | Name | Name |
| | Address | Address | Address |
| | Phone | Phone | Phone_Number |
The Add Mobile form is used by the company to add products that are up for sale. Data is fetched from this form and displayed in the widget. The code for the same is written in the attached JS file. The Orders form is for customers to purchase the required product.
Import data from the attached xls file. Images can be inserted separately for each record after importing.
16.
Add a widget in the page by clicking
Widgets >
Create Widget.
17. Enter Widget details, and click Create.
Note: The zip file can be found in the dist folder of your project directory. This is mentioned earlier in step 13.
18. Now, drag and drop the widget on the Page builder.
See how it works
Points to note
- When entering commands, there is no need to enter the dollar sign ($) explicitly, it would already be present by default.
- Ensure the image fields are visible in the quickview of the List report.
- node and npm are predefined package managers that are used to run zet - zoho extension toolkit
- If the widget.html file does not open in Sublime or Visual Studio, move it to another accessible folder.
- Index file should be in the format /<widgetfilename>.html.
- You can use permissions to hide the Add Mobile component from customers.
- Widgets
- Pages