Skip Navigation

[Resolved] Insert script using javascript src (instead of a script you can wrap)

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by Mark Sund 6 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#905912

Tell us what you are trying to do? Insert a javascript call to an external source in a Content Template (or any way that it's possible in the content area); the code we need looks like...

<script type="text/javascript" src="//destinilocators.com/identiferhere/site/install/"></script>

So we can't insert it in the JS Editor area, because that wraps it in script tags. The script tags are already there and can't be taken out because of the src attribute that gets the actual script. This script gets an iframe and inserts it just after the script tag.

This is for this use case (Destini displays a store locator for retail products), but we have other sites that do similar things (job listings and such) and we'd like to know we can use Toolset for these cases.

Is there any documentation that you are following? Yes...

https://toolset.com/forums/topic/how-to-invoke-a-js-function-in-view-editor/

https://toolset.com/documentation/user-guides/adding-custom-javascript-views/

Also a resolved Toolset thread about enqueing scripts I can't find now. We enqueue scripts all the time with WordPress sites. But we can't get it to work with Toolset. We'd need to embed or register the script in functions.php, then call it in Toolset. It's called the registered script that we can't figure out.

Is there a similar example that we can see? Here's the exact same script but on a different client's website. On that site we just inserted the script in a template file. But we'd rather do it the right way in Toolset.

hidden link

What is the link to your site? Trying to make this work here. We might be working on this page, so what you see might not be relevan)...

hidden link

Thank you for your help,

Mark Sund, Studio Director, Sund + Co (Cincinnati USA)

#905984

Hello,

In your case, you just need to put the HTML codes into Views content directly, for example, edit your view, in section "Output Editor", add your codes before all other Views codes, like this:

<script type="text/javascript" src="//destinilocators.com/identiferhere/site/install/"></script>
[wpv-filter-meta-html]
[wpv-layout-meta-html]
#906383

Luo,

I replied by email, but here in the web-based ticket window, it doesn't show up. (Oh...... I see that address says noreply@) Here's my reply!

Luo,

That worked – thank you. It’s kind of a roundabout way to insert a script, I can’t find a way to make it not run the query, only run a query that returns no results, and then it makes me display the output (albeit empty) just for it to honor the script src I inserted. In any case, it does the trick! Thank you,

Mark