You learned in the previous video how to make a page based on a record in your Ontraport account using dynamic page templates. That’s really cool but sometimes instead of making a whole page about a particular record, what you need is a list of records on a single page.
You created a page for each pet that goes to your veterinarian clinic. That’s good but you also want to have a page for each client that lists all their pets on it, and you want them to be able to click on each one to get to that pet’s page.
You can do that — and a lot more — using dynamic blocks.
Just as a dynamic page is created for each record in your object, with dynamic blocks, you’ll design a block the way you want it to look, and the whole block will be repeated with data from each record.
I’ll show you how this works.
You’ll start with just a regular Ontraport page, your pets overview page. You’ll pull in your page header from your global blocks to make it look nice, then you’ll add another block underneath that. This is going to be your dynamic block that lists your pets.
Click the gear icon to enter layout mode. You’re going to see your new database icon up here. Just as you can convert a block into a global block by clicking on the globe icon, you can now turn it into a dynamic block by clicking the database icon.
When you do that, you’re going to see a dropdown field that lists all the objects you can use as a basis for this dynamic block.
You could create a list of contacts here, or pets or whatever else you may have set up in your account. But in this case, you’re going to keep scrolling down until you see a second section of fields that says “Related to visiting contact.” Here, you’ll find all the objects that are children of contacts, including their files, open orders, transactions, products purchased and whatever other custom object relationships you’ve created.
At this point, I have to pause to remind you about data security. The system is going to show the data for whoever it thinks the visiting contact is, based on data from cookies or login information.
Please remember that tracking with a cookie is not 100 percent accurate or secure. For example, if someone forwards an email to their friend and their friend clicks the email — well, they’re going to think that friend is the one who clicked on it!
If you’ve put a page up on the web that lists your contact’s files, and maybe one of those files is confidential, the contact’s friend is going to be able to see it. So, be cautious about what data you use in these pages and blocks.
The best plan is to protect these pages by putting them in a membership site. Then, people have to log in with a username and password to see your content. That’s far more secure and will limit the exposure of personal data to only people who have login credentials. It’s also more reliable, because sometimes people clear their cookies, which would make it impossible for the system to show anything at all in your dynamic block, if it’s based on data in the contact record.
With that out of the way, go ahead and select “Pets” for your object, but not the one on top because that’ll show all of them. Select the one down here that’s related to the visiting contact, since you only want to show the pets owned by the visitor.
Ok, boom. That’s done.
Now, you’ll see that the system has added “Next” and “Previous” buttons. Those are there just in case a crazy bird lady logs in with her 47 birds and needs to go through each page to see them all. Loading up 47 birds on a page can take some time. But most of the time, people are just going to have 3 or 4 pets at most, so those buttons won’t appear.
Now you’ll design this block just like you did with dynamic pages. Drop a picture on here, a subheadline and then another text section.
You’ll start by connecting these elements to your database records. When you click on this, you’ll see that you can choose from fields in the visiting contact’s record or fields from the record that this dynamic block is based on. Choose the latter and then connect this to the main photo of your pet.
Next, you’ll connect the subhead to the pet’s name in the same way.
In this text area, you’ll do things a little differently. You’re going to share three different fields from the pet record using merge fields. So just type this out and insert merge fields using the merge field tool up top and it’ll end up looking like this.
So, you’ve designed one block here and these will get filled out with one of the visitor’s pet’s data and the block will get repeated for every pet your visitor has.
Let’s see what this looks like.
In order to do that, you’re going to go back up to the “Preview Data” menu, and you’ll see that there’s a new option that says “Contact.” This allows you to see the page as your contacts will. So select Moira Rose here, and you’ll see her pets when you preview the page. If you change this to Johnny, you’ll see his pets instead.
This is good stuff! But there’s something missing. You need the user to be able to click on each of these pets on the list and go to the dynamic page for that pet. That’s super easy to set up.
Add a button on here and make it say “See Details.” Then click the link editor, and you’ll see a new option here that says “Link to a page related to the displayed record.” If you click on that, you’ll see the available page types for that object. Pick the one you called “Pet Details,” and you’re done.
Now, each of these links will go to the related record’s pet details page. Perfect.
I want to show you another feature that’s going to be really useful. To illustrate it, imagine that instead of wanting your pets all listed together here, you want to separate lists of pets based on the sort of animal they are. Cats in one list, dogs in another and so on.
Being able to filter your dynamic blocks to only include certain kinds of records will be useful in all sorts of different use cases, including many of the common features that I’ll show you in a bit.
Simply add a condition to your dynamic block so that it only includes pet records where the type of animal is a dog. You’ll do that by going into layout mode, then clicking on your dynamic block settings in the left palette. At the top, you’ll see that you can add conditions here and you’ll simply add a condition where the pet type equals dog. Click “Done.”
Now when you preview this page, you’ll see that there are only dogs here.
The next step would be to copy this block and then set up the condition so that you only include cats.
While you’re here, I’ll point out some other features. You can decide how many records you want to display when someone first visits your page. The more records you load, the longer it’ll take, so you might want to keep this number under control but 60 is the maximum.
If there are more records than whatever you choose to display in your initial load, the system will show the “Previous” and “Next” buttons so people can click through the results.
That is, unless you select “None” here. In that case, those buttons won’t show up even if there are more records to see. This will be useful in cases where you want to just show a few records.
For example, maybe you have a collection of testimonials, and you want to show testimonials from people in the same industry as your visitor. But you don’t want to show a ton…maybe just the first three. You could use a dynamic block for that. Put three testimonials in the initial load setting, then remove the “Previous” and “Next” buttons by clicking “None.”
Finally, you can sort the order and direction of your records. This lets you decide which records should show up first. And that’s it.
Now you’ve got your list of dogs up top, then your cats. You could even add some headlines in between to make it clear. One could say “My dogs” and then you’d copy that, move it down, and change it to say “My cats.”
With that, we’ve wrapped up our tour of the dynamic blocks features. It’s pretty simple, really.
But you’ll see that when we start getting into the Common Features section in a few minutes, you’re going to get really clever with how you use this stuff to create some very sophisticated apps.
Before you do that though, I have a few more subjects to cover. I’m going to explain page types and how to get your pages published and live on the internet in the next video. So let’s get to it!