Skip to main content

inserting global javascript

I'm trying to include a block of javascript code in the footer of the courses section of the 'portal'. The code should be inserted into every lesson page but is not. I'm using the 'WPCode' 'Headers and Footers' plugin to insert the javascript. It works fine on normal WP pages, but not on the lesson pages (and I assume not on any portal pages). Does the portal not follow the usual WP standards? If so, then how do I add custom js into the portal pages.

Dennis Asher

I'm trying to dynamically load html files into lessons. I'm a bit stunned that the lesson editor only allows the most basic html content so my solution was going to be to maintain the lesson content in separate html files and dynamically load them into the lesson. Even that is proving difficult and then i realized this is a react app, not just standard html pages.

I used console to identify the div containing lessons and tried to load content into it using js. I tried waiting for dom completion and also waiting for the div to be available but neither worked.

Not sure if there is a solution now.

Dennis Asher

loading the html in an iframe, using the media section, works except that the height I set of the iframe is totally ignored. It's really only useful video (or very short lessons). After using a learndash/buddyboss combo (very slow on anything but custom hardware) I was attracted to fluentcommunity by its potential speed and simplicity. The performance is achieved using React but that is making it very difficult to customise.

Ross FCA

Dennis AsherΒ what's your preferred method of working here and I can try include it in the plugin I'm working on? I'll be looking at courses soon to hopefully enhance the editor and add course overviews to the top of the page.

Dennis Asher

Ross HΒ thanks. iframe doesn't really solve the problem. I need to be able to hand-craft sections of html within lessons. My attempts to use js in the website footer to dynamically insert html/js content hasn't worked:

let targetElement = document.querySelector(".fcom_lesson_content.feed_md_content"); targetElement.innerHTML = fileContent;

The portal doesn't seem to include the standard footer content.

For now, I've abandoned using the courses part of FluentCommunity. I'll create the courses as standard html pages and hopefully there will be an api I can use so I can still take advantage of FluentCommunity reporting, leaderboard etc.