Designs - Creating Templates

Designs - Creating Templates

You can create your own templates

In Designs you can create templates. The notion of a template is something that is reusable or can be a pattern for multiple purposes i.e. Blasts, Listing Flyers, Share and Embed, etc. Did you know Designs employ a very powerful templating framework which allows you to build templates that merge in data dynamically when they are used?

Let us provide a very simple example of how this works. Every listing has a name, address, price, and much more. This is its data.  Let us say you have the listing for the Munster's Mansion. Imagine a template something like...

{{ListingName}}
{{Address}}
{{Price}}

When it is time to display the template, the listing's data is merged together with the template and the result becomes...

Munster's Mansion
1313 Mockingbird Lane, Mockingbird Heights, CA 12345
$1,500,000

 

What does the data look like?

RealtyZapp provides an extensive set of data for use in any deisgn. Below is a illustratoin of the data at your disposal...

  • agent
    • Name
    • FirstName
    • LastName
    • ...
  • company
    • Name
    • Logo
    • StreetAddress
    • ...
  • listings [0 ... n]
    • Id
    • ListingName
    • Price
    • Photo
    • spaces.[0 ... n]
      • Suit
      • Floor
      • AvailableSqFt
      • ...
    • photos.[0 ... n]
      • Title
      • Description
      • photoUrl
      • ...
    • agents.[0 ... n]
      • Name
      • Title
      • PhoneWork
      • ...
    • ...

In reality there are a lot more data elements but hopefully you get the idea. Note that the agent and company data elements are pretty simple (flat) whereas the listings element is comprised of a list and each listing has elements like photos which is a list of more things.  

In the template example above, {{ListingName}} is a data merge token. Typically these tokens represent the data field name but there is more to the syntax than just that. Let us explain by providing some examples...

{{Name}} = agent's name.
{{photos.[1].photoUrl}} = the listing's 2nd photo, not the 1st photo. 
This is becasue data lists use [0] = 1st, [1] = 2nd, [2] = 3rd. Get it? {{agents.[0].Name}} = the listings 1st (primary) agent.
Yes, listings can have more than agent.

So, how do you know if {{Name}} is referring the agent or the company as they both have a Name field? That is where rest of the templating syntax comes into play so let us go over some features of the templating framework... 

{{@root.agent.Name}} or {{@root.company.Name}} - @root means starting from the tip top of the data tree. Think of it like a full address to the data element.
{{#with @root.agent}} ... {{/with}} - a context wrapper where everything in between {{#with ...} and {{/with}} is assumed to be in the context of the agent data branch. Inside the wrapper you can simply use {{Name}}. 
{{#each @root.listings}} ... {{/each}} - loop over each and every listing in the listings list.
{{#if Lease}} ... {/if}} - if the listing.Lease field is true, everything in between will be displayed. If listing.Lease is false then everything inbetween will be omitted.

Templates in the wild

In many of the built-in bloks and pre-made templates employ the templating syntax. The Agent, Company and Listing type bloks all employ just about every form of the templating syntax. Given the Listing blok for example, in order for it to not only loop listings but loop only certain listings it utilizes a special context...

{{#getLids ~lids~} ... {{/getLids}}

where getLids is a custom function that will loop only the listing(s) you have selected. Additionally, getLids function has super powers and can figure out that the listings are relevant to when and where the template is being displayed.

When designing a template for Blasts, these bloks are pretty simple things that you just drop into you design. In the case of PDF Flyers and Web Pages, these things may be big wrappers that encase all of the objects of the design. For example, the 2 Page Listing blok is actually a Listing thing wrapped around 2 child page things. You will notice a small tag reading Listing on the side of the listing. This tag serves as both a visual marker and 2) allows you to hover/click on the tag to select the Listing thing. 

This is just the bare basics of the templating syntax. If you want to learn more about templating power...

  • Visit the vast collection of templates in the RZ Gallery where you will find all sorts of examples of the templating syntax in action.
  • Visit https://handlebarsjs.com/guide/ as Handlebars.js is the templating framework employed in Designs. 

    • Related Articles

    • Designs

      RealtyZapp Designs have joined the team RealtyZapp is a game changer in the Real Estate world and Designs is our MVP. What are Designs?  Let RealtyZapp Designs bring your brand to life in the form of rich HTML email blasts, pixel perfect full color ...
    • Designs - Template Concepts

      Delve into Design Templates Let us now delve deeper into the concept of design templates so you can realize all of the value that RealtZapp brings you. Sometimes it is necessary to use HTML comment elements to wrap around the templating code ...
    • RZ Designer - Tour

      RZ Designer is our drag-n-drop, WYSIWYG builder. With RZ Designer, you can build responsive HTML emails, PDF Flyers, and fully functional Web Pages. RZ Designer is employed in two of your Dashboard modules - Designs and Blasts. Let us assume you have ...
    • RZ Designer - Tour waypoint #3

      Our final stop but not the final destination On our final stop of this tour, we will visit the designer's canvas and perhaps even create a work of art. Canvas Are you are staring at your designer's canvas right now? Did you start with a template from ...
    • RZ Designer - Export/Import

      Export/Import - What for? We can think of couple reasons why but you can probably image many more. You can export your RZ Design in several different formats. Typically your intentions are to use the code somewhere other than ReatlyZapp. We try ...