As per the title, I am looking into a solution to autoplay of the bootstrap 4 carousel slider from Boost. There are some very interesting posts on the Moodle forum that suggest this has been a known problem for a number of years: Of note, the following post back in 2017 from Gareth for Bootstrap 3 looks like the closest solution so far:
As a follow up, Mark was looking for the same type of answer in 2018 but sadly, the solution was not posted.
I have managed to achieve some successes but not the perfect solution. These solutions include using JS to force cycle through the slide in combination with: http://kenwheeler.github.io/slick/. I can make this work but lose transitions.
My other successes include using the slick slider outright on a specific part of the carousel, but in doing so, breaking formatting with divs and using a old school way of formatting with tables inside the slide. Arrows will not work and I need to enable dots: true.
Through the JS console, I get the following error when trying to load in jQuery through Moodle in my theme when trying to autostart the slider:
jQuery.Deferred exception: $(...).carousel is not a function TypeError: $(...).carousel is not a function
at HTMLDocument.<anonymous> (http://moodle.local/?redirect=0:2193:26)
at process (http://moodle.local/theme/jquery.php/core/jquery-3.5.1.js:3830:12) undefined
Which indicates that the bootstrap carousel is not active in the theme in the same way as before. Previously, I would see the notice:
Bootstrap initialised first.js:34
This initially lead me to believe that the same issue is present from the earlier forum posts, now presenting itself in Boost themes. My idea to solve this include adding in the AMD module from Boost which I presume is located here:
and through something like: //$PAGE->requires->js_call_amd('theme_boost/carousel.min', 'init');
though I have not used this technique before and I do not know the frankenstyle name to access the file. Full path:
My thoughts are, if the AMD JS can be loaded, then it can be activated by the js. However, I discounted this thought because when the page containing the slider is fully loaded, then I can activate the trigger directly in the JS console through:
So, this implies that the code is ready and active after the page loads up completely. Therefore, I think I need to concentrate my solution on activating the jQuery as the very final step or activating the carousel bootstrap code earlier on in the process. Code in the footer itself does not work.
Additionally, I completed the steps recommended by Mary in the second post and altered the data-ride to carousel. I tried a few of solutions but nothing worked.
I will keep plugging away at this but if anyone has already solved this problem, it would be really helpful if you could share.
Moodle v3.9 LTS