Hi all,
I’ve just released a plugin which is designed to generate dynamic content in a similar way to how mail merges work.
You can iterate through a list of things and use the data from the fields to insert into your content using tags as replacements. For example, if you had 200 users in your database and wanted to send them all the same message (or generate the body of an email) but change certain things like the name, email, phone number etc then you can do that by inserting tags within the initial content.
Each tag is read and replaced with each row of data until you end up with a generated list of 200 raw text messages all with individual content included.
If any of your fields contains another list of things, then you can specify a field for the secondary list and it will retrieve the data for each item there too. Works slightly differently depending on whether a list of standard Bubble fields are detected or whether it’s a custom user fields but the result is the same which is a comma separated string list of those field values for each data type in the list.
Dynamic content can be written in either plain text or HTML if you prefer. You can feed the content in from other sources and then let the plugin generate whatever you like from it.
It’s quite powerful really!
PLUGIN
Dynamic Content Generator Plugin | Bubble
DEMO*
https://paul-testing-4.bubbleapps.io/dynamic_content
The image below is just a representation of the data available in the User table where some of the fields are made editable. Each field has a tag assigned to it which you stipulate through the element field options. Feel free to add/edit the data on this demo page because if there’s a loads of records it’ll be a nice performance test.
The configuration for the element is like so, where up to a maximum of 15 fields can be configured. All documentation fields are populated describing how it works.
Below outlines a list of all events, actions and documentation.
You can view the editor here: Dynamic Content Editor | Bubble Editor
ELEMENTS
Dynamic Content
This visual element is required to be placed somewhere on your page.
-
Data type
Select your data type so you can see a list of fields to choose from below. -
List of records
This should be a list of items for your selected data type. Content will be generated X amount of times, where is X is the count on this list. -
Replace null values
If a null value (or empty field) is found then you can replace it with some text of your choice here. -
Dynamic content
This is your content, it can be standard text or HTML. You can use this to write a document, an email, an invoice etc and insert tags which represent the fields configured below. These will be replaced with the corresponding field values in your list. The output will be a list of texts where each text will be ‘this content field’ with all the replacements made. -
Custom content 1, 2, 3
Use these fields to create your own custom list from data within your list of records. For example, this could be used to create a unique subject for emails, where you may want to specify the user’s name like “Welcome [{first_name}]” or “Invoice [{invoice_number}] details”. When using tags to represent any data, it must be configured in one of the fields below for this to work. Items numbers in this list will match up with the item numbers in the list of content. If no data is available then it will be replaced with the null value option above. -
The 3 fields below (all for Field 1) are duplicated through the editor options so you have up to a maximum of 15 fields to configure. They'll be a set for Field 2, Field 3, Field 4 etc.
-
Field 1
Select a field where data will come from. -
Field 1 List value
If Field 1 is of another list of data types, then enter the field name that contains the data you want to return. This will tell the plugin what field to pull the data from for each item in this secondary list. Please don’t point this to another list of things, it’s not coded to go another level deep with lists! Data is returned in a comma separated string. The field name is case sensitive. -
Field 1 Tag
This is the replacement tag that will be looked for in the content and replaced by the value coming from Field 1, keep this to something unique. The tag is case sensitive!
EVENTS
- A Dynamic Content - has finished generating
Triggered when the content has been generated.
ACTIONS
- Generate content
This action will generate the content. There is no configuration for this.
EXPOSED STATES
-
Content
This is a list of texts, where each item will contain the generated dynamic content. -
Custom content 1
This is a list of texts, where each item will contain the generated custom content 1 value. -
Custom content 2
This is a list of texts, where each item will contain the generated custom content 2 value. -
Custom content 3
This is a list of texts, where each item will contain the generated custom content 3 value.
As far as events, actions and states go I’ve kept this relatively simple, but if anyone wants additional functionality added then let us know!
Regards,
Paul!