All Collections
Advanced Topics
Installation for Contentful
Installation for Contentful

Contentful and similar CMSs assemble the page dynamically via javascript and require a modification to the installation code

Michael Fatica avatar
Written by Michael Fatica
Updated over a week ago

Some content management systems dynamically assemble the page contents using Javascript when the page loads. In these CMS's, an alternative MetaLocator installation code snippet can be used.

Step 1. Obtain your Interface ID as shown below:

Step 2. Update the below snippet replace the single occurrence of XXXXXXX with your Interface ID.

<!-- MetaLocator.com Code START -->
<script data-metalocator="locator" data-metalocator-itemid="XXXXXXX">
var ml___thisScript = document.querySelector('script[data-metalocator="locator"]');
var ml___Itemid = ml___thisScript.getAttribute('data-metalocator-itemid');
function ml___showLocator(Itemid){var divId="___ml_container"+Itemid,div=document.createElement("div");div.setAttribute("id",divId);var domWrite,thisScript=document.querySelector('script[data-metalocator="locator"]');return thisScript.parentElement.insertBefore(div,thisScript),(function(){var c=0;function evals(pString){for(var script,scripts=[],regexp=/<script[^>]*>([\s\S]*?)<\/script>/gi;script=regexp.exec(pString);)scripts.push(script[1]);(scripts=scripts.join("\n"))&&eval(scripts)}return function(t,e){var r="string"==typeof t?document.getElementById(t):t,n=document.createElement("script"),i=document.write,o="",a="",l="",m=100;function s(){o!==a?(a=o,l=window.setTimeout(s,m)):(r.innerHTML=o,evals(o),0==c--&&(document.write=i))}document.write=function(t){window.clearTimeout(l),a=o,o+=t,l=window.setTimeout(s,m)},c++,n.setAttribute("language","javascript"),n.setAttribute("type","text/javascript"),n.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(n)}})()(divId,"https://code.metalocator.com/index.php?option=com_locator&view=directory&layout=_javascript&framed=1&format=raw&tmpl=component&no_html=1&Itemid="+Itemid),setTimeout(function(){null!==document.getElementById("locator_loading"+Itemid)&&(document.getElementById("locator_loading"+Itemid).style.display="none")},1000),!1} ml___showLocator(ml___Itemid);
</script>
<!-- MetaLocator.com Code END: Do not modify this code block. See TOS for details. -->

Step 3. Copy the completed code to your Website where you would like the locator to appear.

Did this answer your question?