Embed script with API key

Apologies for the newbie question…

I am trying to embed a few lines of simple javascript in on page, but it clearly isn’t working. I’m sure there is just something basic I’m missing the documentation suggests that there is an elaborate solution, which I’m struggling to follow with my current understanding of Grav.

The code structured like this (“site.com” in the example is a url external to the Grav site I’m building:

<script type="text/javascript">app_id="APP_ID_HASH";</script>
<script type="text/javascript" src="https://SITE.COM/FILE.js"></script>
<div id="SOME_ID">Loading...</div>

If there is just something conceptual about Grav I don’t understand, please feel free to point me in the right direction. Or if there is a model to follow that would be great too.

Thanks!

Okay, but what actually is this supposed to do and how it doesn’t work?
To help you solve your problem, one would need, well, some more details.
Where did you put this code? What did you expect it to do? What it actually did? Was there any code rendered in the final source? Were there any console messages?

Cheers!

The code displays a form from an external app. I have extensive experience embedding this app on other PHP CMS’s like Joomla and Pagekit. Works fine each time.

I put the code in a Modular which I then added to an existing page.

There is no console error. The code does not display.

I performed the following test to make sure the Modular was displaying:

  1. Remove script
  2. Add simple text.
  3. Save and refresh

Simple text displays exactly where I would expect. However, searching the for the Modular id in the console reveals that it is not there which also seems odd.

Thanks for any input.

You mean you’ve put bunch of <script … /> tags in the module’s .md file, did I get you right?

To be precise, I place two lines of tags and one line of

tags in the admin after Add Modular.

Maybe try this:
Insert all those pretty tags in special Template (Twig ) file, and then add a module using this template to your modular, in the place where you’d like this form appear, and let me know what happens :slightly_smiling_face: