TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Majd Edriss -
Number of replies: 14

I installed Moodle 2.6.0 and created a custom Theme based on bootstrapbase.
To Display the blocks I used the same way as in bootstrapbase: echo $OUTPUT->blocks('side-pre', 'span4 desktop-first-column') and echo $OUTPUT->blocks('side-post', 'span3')...
When I turn on the edit mode on my home, I got the Error in the firebug console : TypeError: node is null.

This Error appears with Clean and Essential Themes too!

Suggestion to fix: I got it from this ticket MDL-40446

lib/yui/build/moodle-core-blocks/moodle-core-blocks.js
lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js

< hasblocks = node.all('.'+CSS.BLOCK).size() > 0,

I changed it to

> hasblocks = (node != null) && node.all('.'+CSS.BLOCK).size() > 0,

Can anyone reproduce this with Clean or Essential?

Attachment moodle260_clean_editing_YUI.png
Average of ratings: -
In reply to Majd Edriss

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

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

Hi,

Check that your mark-up contains the class 'block-region' for your 'aside' tag when rendering the block....

Probably down to that or broken structure in the layout file as 'create_and_add_node' cannot find the block on line 818 of 'moodle-core_blocks.js' (human readable one, in reality the 'min' one is used).  Especially as you have a block region called 'content' initialising, which is odd.

Please post a similar screen shot.

Cheers,

Gareth

Attachment 2013-12-09 15_31_22-Course_ Grid.png
In reply to Gareth J Barnard

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

There is a problem with MyDashboard (My Home) MDL-42953

Average of ratings: Useful (2)
In reply to Mary Evans

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

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

Thanks for the link on tracker Mary, I can replicate on Shoelace.

In reply to Gareth J Barnard

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

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

Hi,

In 'moodle-core_blocks.js' the logic here looks iffy:

        // Add relevant classes and ID to 'content' block region on My Home page.
        var myhomecontent = Y.Node.all('body#'+CSS.MYINDEX+' #'+CSS.REGIONMAIN+' > .'+CSS.REGIONCONTENT);
        if (myhomecontent.size() > 0) {
            var contentregion = myhomecontent.item(0);
            contentregion.addClass(CSS.BLOCKREGION);
            contentregion.set('id', CSS.REGIONCONTENT);
            contentregion.one('div').addClass(CSS.REGIONCONTENT);
        }

 Given that

CSS = {
    BLOCK : 'block',
    BLOCKREGION : 'block-region',
    BLOCKADMINBLOCK : 'block_adminblock',
    EDITINGMOVE : 'editing_move',
    HEADER : 'header',
    LIGHTBOX : 'lightbox',
    REGIONCONTENT : 'region-content',
    SKIPBLOCK : 'skip-block',
    SKIPBLOCKTO : 'skip-block-to',
    MYINDEX : 'page-my-index',
    REGIONMAIN : 'region-main'
};

 Given that I think " > .'+CSS.REGIONCONTENT" looks for a tag with that class but then adds the same class?

My CSS knowledge is not yet brilliant on use of the '>' operator.

Cheers,

Gareth

 

In reply to Gareth J Barnard

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

No wonder it is not working all those divs being added.

It is obvious that the developers have no idea how the layout files work in Moodle standard themes let alone Bootstrap based themes.

In reply to Gareth J Barnard

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Majd Edriss -

Thank you Gareth for the reply.

My mark-up contains the class 'block-region' for aside.
Hier is a screenshot

 
Attachment moodle260_custom_structure.png
In reply to Majd Edriss

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi, I am sorry to say there is little you can do at this stage , only wait for this 'bug' to be fixed as it is a script error and nothing to do with the theme.

This is so frustrating for everyone.

Thanks you for your patience.

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Majd Edriss -

OK thank you Mary...

My workaround in the moodle-core-blocks.js works for me for the moment until this bug is fixed smile

In reply to Majd Edriss

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

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

Dear Majd,

Thank you so much for posting the screen shot.

Kind regards,

Gareth

In reply to Majd Edriss

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Xavi Montana -

I had the same issue, an I have tried various bootstrap's themes. In my case, it happens when I hide the Navigation block inside a resource (SCORM, PAGE..) or in the index course, because we like to see the contents without columns.

Majd, there is any ticket opened about this issue? Or we need to reeopen MDL-40446, because is closed (and not relevant to this comportment). Is very important because the use of bootstrap's themes are increasing.

Thanks!

In reply to Xavi Montana

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi, C an you tell me which Moodle version you are using. Is it 2.5.4 or 2.6.1?

In reply to Xavi Montana

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Majd Edriss -

Hi Xavi,

I didn't find any Tickets for this issue. Does this error appear when you move or dock the blocks? Or just when you hide these?

In reply to Majd Edriss

Re: TypeError in Clean, Essential and custom Theme - Moodle 2.6.0

by Xavi Montana -

Hi Majd,

Just when I hide the block.