All Collections
Legacy Interfaces
Legacy Form Settings
Legacy: Using the MetaLocator Templates
Legacy: Using the MetaLocator Templates
Bryan Nye avatar
Written by Bryan Nye
Updated over a week ago

Important: This article describes a legacy software feature and should not be used by customers starting with MetaLocator since 2019.

MetaLocator Templates allow you fine control over the display of the fields within your MetaLocator database. Through the use of specially formatted tags, the templates allow you to re-arrange fields, hide fields and also control the display formatting of fields. Templates also allow you to include custom HTML within your individual locations, allowing for exceptional control and customization of your locator.

There are 4 templates in each Interface. They are as follows:

  • Directory Item Template

  • Map Popup Template

  • Detail Page Item Template

  • Detail Page Map Popup Template

These templates appear in your Interface in different locations based on your settings. This graphic shows the location of the first two address templates within the Interface Layout.

 

To edit these templates, find them under your Interface settings, in the Template Settings group.

Click the green MetaLocator Fields button to open the Field Chooser.

You can choose and add MetaLocator fields directly from list list.  If you prefer direct control of the template, or you wish to add special HTML to these layouts, click Source from the editor toolbar to reveal the template markup.

Additionally, there are two templates for the item detail pages. These are the pages you see when you're viewing a single location.  You can find these formats under the Template Settings group of your Interface Settings:

 

Within each template, you'll find template markup that includes the various fields that will be used to display the actual location data. A common default Template is:

{title}{distance}<br />{address}<br/>{address2}<br/> 
{city}, {state} {postalcode}<br/>
{phone}<br/>{link}<br/>{email}<br />
{description}

 

This formatting used to dynamically display the location data. Adding, moving and removing fields and markup within this template will change how your location data is displayed for a given Template. The default above includes standard fields that a typical user would expect to see when searching your database. If, for example, you do not wish to include the display of your "Address 2" field within the Interface, simply remove the {address2} template markup from the Template and save your Interface settings.

Template markup tags are named according to the field they display. If you have added custom fields, a new template tag will be created according to that field's name. You can see all of your field tags shown in the Field column, found under "Fields". Additionally, other fields including:

  • {title} - The location name which is automatically linked to either the detail page or the map marker popup depending on configuration.

  • {text_name} - A plain-text version of the location name.

  • {introtext} - Description field text found before a "Read More" separator

  • {fulltext} - The complete description field, synonymous with {description}

  • {resttext} - Description field text found after a "Read More" separator

  • {distance} - The formatted distance description. Distance is only populated if the user performs a distance-based search and provides a location in the process.

  • {directions} - A link to Google Maps directions.

  • {internal_directions} - A link to internal directions system.

  • {itemid} - The internal system ID number of the Interface.

  • {id} - The internal system ID number of the Record.  This category can be used to build links to other MetaLocator Item pages.  An astute user may notice that Item Detail Pages are constructed in a standard way and include the Itemid and id number.  Markup such as <a href="index.php?option=com_locator&view=location&layout=default&id={id}&tmpl=component&Itemid={itemid}">Click here</a> will be dynamically updated to a correct link for that location.

  • {offset} - The zero-based offset of the search result.

  • {number} - The 1-based number of the search result.

  • {lat} - The latitude of the location

  • {lng} - The longitude of the location

  • {taglist} - A comma-separated list of Categories associated with that location (they must also not be excluded under the locator's Category settings). Note that Categories are referred to as "tags" within the code, hence taglist.  Taglist can also be filtered by a Category Group name, as in {taglist tag_group="Name of Category Group"}.  In this way, you can filter out certain categories from the front-end display.

  • {streetview} - A Google Streetview image of the latitude/longitude of the location.  Also {streetviewbig} for a larger map image.

  • {eventstatus} - The status of a location (typically an event) based on the start and end dates of the location. Values include "Past","Today", "Upcoming" and "Ongoing".

  • {todayhours}.  This displays the hours for the current day in a textual format, as in “Open today from 9 to 5”.  It also includes when the location is open next, if it is currently closed.

  • {locationstatus}.  This displays “Open” or “Closed”.  It’s default styling includes a green or red font color, respectively.  See this post for more information on showing real-time hours indications.

  • {type} - The value of the Type field

  • {clr} - Includes a DIV tag that forces a CSS clear.

  • {details} - A link to the location detail page.  In the static Location Landing Pages, this is replaced with the SEO URL of the generated page.

  • {review_summary} - A short narrative sentence, X reviews for an average of Y stars. This language can be overridden by providing overrides to the language constants below..

  • {review_stars} - A dynamic stars image which shows the rating as a series of stars.

  • {review_list} - The complete list of reviews for a given location including comments, reviewer name, date and stars

  • {details} - A link to the location detail page.

  • {sharethis} - A set of "ShareThis" links. You must also configure a ShareThis Publisher Id in your interface settings.  Also {sharethissmall} for smaller icons.

  • {name_ml_raw} This is a plain-text version of the location title.  Normally the title includes a link that has some dynamic behavior which can be unwanted in certain scenarios.

  • {fieldname_ml_raw}  Where field is the "safe" version of the field name outputs the plain-text version of any field.

  • {fieldname_label} See this post for more information on dynamic labels.

  • {googleembedmaps} A location-specific google map derived from Google's quota-free places map embed.  This map may contain content from Google places and is not configurable.

  • {locationmap} A location-specific map, commonly displayed on the detail page

  • {timezone} The time zone of the location as detected by the MetaLocator geocoding process.

  • {rss url='http%3A%2F%2Fwww.feedforall.com%2Fsample-feed.xml'} An RSS feed.  Notice the URL must be url encoded.

When template tags are replaced with actual data during the record rendering process, they are most often wrapped in an HTML div tag which includes a class name specific to that field, allowing for detailing CSS styling control.

HTML markup is also allowed within the Templates.

Based on the field type, certain formatting changes are implemented. Field types are shown in the Type column, found under "Fields". Field types include:

  • text: The most common and default field type. Wrapped with an HTML span tag, that includes a line_item class and also a class with an CSS-safe version of the field name.

  • email: The system expects to find email addresses in this field and will dynamically convert them to mailto links.

  • email_form: The system expects to find email addresses in this field and will dynamically convert them to a link to a Contact Form.

  • link: The system expects to find hyperlinks in this field and will dynamically convert them to anchor (link) tags. The links will be assigned a target="_blank" to open in a new window if "Open Link Fields in New Window" is set to "Yes" under the locator's Advanced settings. The hypertext (e.g. the clickable part) of the link will be the link itself, unless the template tag is expanded. If you would like to use another field as the "hypertext" of the link you can format the tag as follows: {link {title} /link}.  All custom fields of type "link" can be used in this way.  You can also include custom text in this field as in {link Click Here! /link}.

  • image: The system expects a URL to an image, and will include that URL in an HTML IMG tag.

  • meta: Allows a meta tag to be inserted into the document's HEAD. A custom field called "sample" will be created as a "meta-sample" tag, with content matching the value of the field.

  • datetime: A datetime field will be converted to a date according to the locator's Date Format Settings.

  • record:  A link to a list of related records, or the list of records themselves. The system expects the internal ID number as the value of this field.

Conditional Comments

MetaLocator templates support conditional comments.  These comments are placed around a section that should not appear if the field contained in that segment has no value.  For example, some locations may provide data for the "hours" field, and your template markup may include a heading for the location hours:

Without conditional comments the "This is the hours header" content in this template would be repeated regardless of the content of the hours field, possibly causing the system to display headings without any followup content.

Instead, you can wrap the section in a conditional comment, causing the entire block within to be omitted when the hours field is empty.

The format of the conditional comments is

<!-- hours --> 
This is the hours header
{hours}
<!-- hours -->

Where  "hours" in this example is the "safe" name of the field as described above.  Conditional comments do not apply to email_form fields since email_form fields are designed to work with and without location-specific email addresses.

MetaLocator also includes comments that allow certain blocks of template content to be output based on the location's inclusion in a specific category.  In the below example, the content within the comments will only be displayed if the location is included in the Category with id = 7 

<!-- tag_id_7 --> 
Content for locations in tag 7
<!-- tag_id_7 -->

MetaLocator also includes comments that allow certain blocks of template content to be output based on the location's type.  In the below example, the content within the comments will only be displayed if the location is of type "sales".  The word sales should be the "safe" version of the value of the type field, e.g. lower case, no spaces with symbols removed.

<!-- type_sales --> 
Content for locations where the type field = sales
<!-- type_sales -->

For locations with no type value, the following syntax will allow content display:

<!-- type_ --> 
Content for locations where the type field has no value
<!-- type_ -->

Fields of type email_form do not support conditional comments.  If field is a email_form field, and if the email address is missing from the location record, it still presents the link to the email form, instead directing the resulting email to the recipient configured in the Interface settings.   To allow support for conditional comments on email fields, change the field to a different type such as email, or text,

Did this answer your question?