Add javascript code in theme moove

Add javascript code in theme moove

by José Leonardo Miquilena -
Number of replies: 2

Hi Guys

Moodle Version = Moodle 3.8.1 (Build: 20200113)
Moove Theme = 3.8.7

Someone can give me an orientation about how to add javascript code in the frontpage_guest file of the moove template... I want to make a kind of tab of the site's categories. I already have the tabs running using ccs3 jquery, 

I understand that moodle incorporates the jquery library. I managed to place the structure of Tab in the file frontpage_guest with their respective css but to work I need to include the javascript code that would be this:


<!-- animate tabs jquery -->

<script>

$('.tab ul.tabs').addClass('active').find('> li:eq(0)').addClass('current');

            $('.tab ul.tabs li a').on('click', function (g) {

             $dataopener = $(this).attr('data-opener');

            $('.tab ul.tabs li').removeClass('current');

            $(this).parent('li').addClass('current');


            $('.tab_content div.tabs_item').not("#"+$dataopener).slideUp();

            $("#"+$dataopener).slideDown();

                g.preventDefault();

            });            

</script>

I would like to know if anyone can help me or give me an orientation or if you can tell me how I can best incorporate Tab 

Thank you very much.


Attachment tabmoode.png
Average of ratings: -
In reply to José Leonardo Miquilena

Re: Add javascript code in theme moove

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Start here: https://docs.moodle.org/dev/Javascript_Modules - and because the inclusion of the JS is initiated in PHP then you can use the value of the 'pagelayout' attribute of the $PAGE global to only include it on the frontpage layout.