Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Widgets /

Discuss SilverStripe Widgets.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Adding external JavaScript/widget

Go to End



Community Member, 13 Posts

18 July 2012 at 9:04pm


I am maintaining a Silverstripe 2.3.7 site and am frequently getting request to add in small pieces of code for some small functionality that needs to be implemented. The problem is that the code usually needs to target a specific page, for example - I have been asked to implement Learnpipe

See exactly what this is

The people at Learnpipe sent me the following:

Step 1. To ensure Facebook posts include your logo - insert the following code in the
<header> section of the template.
I have inserted this in the /templates/ header
<link rel="image_src" href="
537010_372006922830724_988906636_n.jpg" width="100">

This will ensure that all questions that are shared to Facebook are displayed with the correct
logo. **If this change is NOT made, Facebook will randomly take an image from each page.

Step 2. Social Q&A widget
This is the active widget snippet for your college. Place in an appropriate place within the page
Here's the problem our templates are divided in faculties and then courses but all the computer courses use the same template so in order to target a particular computer course I need to add this java script on the page through the CMS. Initially when i did this the code was just striped I then edited the tiny mce config file to allow JS (extended elements) it stopped stripping but still didn't work. I then tried to use a html page I inserted my JS into the HTML and called it into the page using an iFrame.
<script type="text/javascript" src=""></
<script type="text/javascript">
var lpQA = lpQA({
genQ: "false",
identifier: "your course code"

Variables explained:
appID : fixed and valid widget application ID, which is provided by learnpipe.
identifier: A widget identifier is a unique string which is used to look up/group page questions in the learnpipe
system. Please pass in the coursecode variable here. The relevant course codes are included in the table
genQ: With this option set to “false”, the system treats the page as a course page. With this option “true”, the
system will enable non course specific questions. Use this option for non-course pages (contact, admissions,
accommodation, etc.).

The target page imports the js as below:

<script type="text/javascript" src=""></script>
<script type="text/javascript"></script>

And the iframe is the following:

<p><iframe src="themes/gcd/templates/Includes/LearnpipeBAAFH.html" width="100%" frameborder="0"></iframe></p>

I didn't design the site so i am not an experienced SS developer but do use your great forums just could'nt find any info on this.
Ideally I'd like to find a method of targeting individual page with js if this is possible

Thanks in Advance