In this use case, we will see how create dynamic content using Factory .
Our goal is to display the information in our database by creating a template that will be reproduced for each item
First of all, we will be interested in the back end.
For the needs of the case, we will create the database table ourselves by creating 'Courses'
We created a new table 'Courses'
We will create an new function API of type 'VISUAL SELECT' like this :
Now our backend is configured, let's doing our front end part
We are going to make 2 sections:
Template Section :
- This section will be hidden by clicking on 'Visible only in PageBuilder' option.
- Let's create a template column and give it an id such as 'templateCol' by clicking to the column brush
Coding Section :
Let's add a component Source Code of type JQuery and add this :
Let's check the code :
- We receive the courses from our 'Courses' data table.
- We will iterate through our courses to create a new course using our template whose id is 'templateCol'.
- We add each new course in our div whose id is 'results'.
Let's check the result :