Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Embed script with API key

Started by mark 9 years ago · 5 replies · 674 views
9 years ago

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:

HTML
<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!

👍 1
9 years ago

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!

9 years ago

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.

9 years ago

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

9 years ago

To be precise, I place two lines of <script> tags and one line of <div> tags in the admin after Add Modular.

9 years ago

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 🙂

👍 1

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 64 17 hours ago
Support · by Anna, 3 days ago
2 68 20 hours ago
Support · by Justin Young, 21 hours ago
1 35 21 hours ago
Support · by Duc , 1 week ago
2 71 6 days ago
Support · by Colin Hume, 1 week ago
2 63 6 days ago