Template Synchronization

MetaLocator location pages can synchronize your with your website template

Bryan Nye avatar
Written by Bryan Nye
Updated over a week ago

MetaLocator can extract the template of your Website from the page on which our Interface installation code is installed.  Subscribers to our SEO Add-on can pull the template from their Website to automatically adapt landing pages to their Web site.

This is established as a background process which runs on a regular basis to keep the system in sync.

This process works by finding the MetaLocator interface installation code within the page, and pulling the HTML above and below that fragment for the header and footer. In order for this to work, the fragment must be added to the page *exactly* as provided. We specifically use the HTML comments above and below the code fragment to find the Interface.

To establish the background job, click the process icon in the toolbar and then New. Complete the form as shown below:

Click Save, and then toggle the Published and Scheduled switches to enable the job.

Finally, force the job to run immediately as shown below:

After the job completes, the content of the page provided in the URL will be added to the Website Template setting as shown under the Location Pages tab:

Modifications to the head and title tags from this point forward will not be overwritten by subsequent executions of the synchronization task. This allows Web developers to insert Twig template references into the template so that those aspects can be dynamically populated.

Head Tag

To insert MetaLocator required head tags, the following code block should be added to the Website Template's head tag:

 <!-- START: MetaLocator head tags -->

{% for meta in template_item.meta %} {{ meta|raw }} {% endfor %}

{% for stylesheets in template_item.stylesheets %} {{ stylesheets|raw }} {% endfor %}

{% for scripts in template_item.scripts %} {{ scripts|raw }} {% endfor %}
<!-- END: MetaLocator head tags -->

The head tag brings in all MetaLocator required CSS and JavaScript, including CSS from the CSS setting found under Style & Color settings in the Interface Builder.

Title Tag

The following example markup shows the dynamic assembly of a title tag for both the directory pages and the location pages.

{% if template_item.page_type == 'location' %}
{{template_item.location.name}} in {{template_item.location.city}},{{template_item.location.state}}
{% else %}
All Locations {% if template_item.root == false %} in {{template_item.data[template_item.current_value].label}} {% endif %}
{% endif %}

Page Body

The Interface Installation code will be replaced with this statement:

{{ include(template_from_string(template_item.twig_page_template)) }}

The above placeholder will be replaced by SEO Page Template.

Did this answer your question?