Features

Adding Tally form to Publii CMS builder

2y agoPending

I struggled to get your form to load using Publii and a theme that in it's CSS had display: block enabled for most content categories.

Your support pointed that out for me and I started troubleshooting using different CSS variations, but what ended up working was the following...

In Publii - assuming your page is called /contact.html .

1. Go to Tools and Plugins > Custom HTML : Select "After every page"

2. Insert the following code

<script>

document.addEventListener("DOMContentLoaded", function() {

if (document.getElementById("tally-container")) {

let container = document.getElementById("tally-container");

let iframe = document.createElement("iframe");

iframe.src = "https://tally.so/embed/YOURTALLYFORMID?alignLeft=1&hideTitle…";

iframe.width = "100%";

iframe.height = "500";

iframe.frameBorder = "0";

iframe.style.display = "inline-block";

iframe.style.visibility = "visible";

iframe.style.opacity = "1";

container.appendChild(iframe);

}

});

</script>

This code will load your form on a page with a div as follows:

3. insert this code in your contact page, again, assuming you call it /contact.html

<div id="tally-container"></div>

The code will also exclude other pages from loading this snippet, via the condition

if (document.getElementById("tally-container")) {

preventing it from load unnecessarily on any other pages. (Credit to ChatGPT for that).

Caveat.

I have only tested it with Technews Publii theme, but I assume it should work similarly with other themes if they have display: block in the CSS for pages.

1 comment

  1. Hi Rikard Malmborg, thanks for sharing this!