Moodle Error : page layout file did not call $OUTPUT->doctype()

Moodle Error : page layout file did not call $OUTPUT->doctype()

by Gopal Sharma -
Number of replies: 7
Picture of Plugin developers Picture of Testers
Hello,

 I'm getting the following error on 

 www.mymoodlesite/admin/index.php 

 1. page called is page-admin-index 

2. layout called is 3column

The page layout file did not call $OUTPUT->doctype()
  • line 964 of /lib/outputrenderers.php: call to debugging()
  • line ? of unknownfile: call to core_renderer->header()
  • line 353 of /lib/outputrenderers.php: call to call_user_func_array()
  • line 287 of /admin/renderer.php: call to plugin_renderer_base->__call()
  • line 287 of /admin/renderer.php: call to theme_remui_core_admin_renderer->header()
  • line 853 of /admin/index.php: call to core_admin_renderer->admin_notifications_page()

Same error is appearing on the badges page as well. 

 Thanks for help. 

-Gopal

Average of ratings: -
In reply to Gopal Sharma

Re: Moodle Error : page layout file did not call $OUTPUT->doctype()

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

The DOC type depends largely on how you want to page to render. Currently in Moodle we are using HTML5 for Bootstrap 2.3.2. so the DOC type is just <!DOCTYPE html>

This is added automatically in the layout pages at this point:

https://github.com/lazydaisy/moodle/blob/MOODLE_31_STABLE/theme/bootstrapbase/layout/columns3.php#L39

If you have not added that in your layout file/s then that is the reason it is throwing you that error.

Hope that helps?

Mary

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

Re: Moodle Error : page layout file did not call $OUTPUT->doctype()

by Gopal Sharma -
Picture of Plugin developers Picture of Testers

Thank you Mary for a quick reply.

This really helped a lot. smile


The mistake which I was doing was that declaring the global $OUTPUT variable which is unnecessary .
Here is the code.

/* Default globals */

global $CFG, $PAGE, $USER, $SITE, $COURSE;

$hassidepre = $PAGE->blocks->region_has_content('side-pre', $OUTPUT);

$hassidepost = $PAGE->blocks->region_has_content('side-post', $OUTPUT);

$PAGE->set_popup_notification_allowed(false);

echo $OUTPUT->doctype();?>

<html <?php echo $OUTPUT->htmlattributes(); ?>>

<head>

    <title><?php echo $OUTPUT->page_title(); ?></title>

    <link rel="shortcut icon" href="<?php echo $OUTPUT->favicon() ?>"/>

    <?php echo $OUTPUT->standard_head_html() ?>


My code was looking like as written above but when I used following line of code

$hassidepre = $PAGE->blocks->region_has_content('side-pre', $OUTPUT); 

I thought that I should declare the $OUTPUT global variable before using it.
There  I made the mistake ,
To solve that I've to rollback to previous git commits and see the changes I made.


I really appreciate your help.
Thanks anyways.

-Gopal

In reply to Gopal Sharma

Re: Moodle Error : page layout file did not call $OUTPUT->doctype()

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

Why have you got $hassidepre that is old Moodle way.

You should not need to use that if using Bootstrapbase theme as parent.

Just look at the layout files in /theme/bootstrapbase/layout/colums3.php to see how the page is constructed That is if you are using blocks and not blocks for region, which are the old way of doing things.

The default way is to use blocks and this is all taken care of via javascript which adds body classes for side-pre-only or side-post-only, content-only

You can check this out in Moodle GitHub https://github.com/moodle/moodle

https://github.com/moodle/moodle/blob/master/theme/base/config.php#L182-L184

You need to add this in config.php If using the old method of blocks for regions.

hope this helps.

Mary

In reply to Mary Evans

Re: Moodle Error : page layout file did not call $OUTPUT->doctype()

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

Why has this post and threads been moved to the Developers forum as is really a 'Themes' issue?

In reply to Gareth J Barnard

Re: Moodle Error : page layout file did not call $OUTPUT->doctype()

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

It wasn't moved it was added here by the poster, I got to it via this link which he posted in the Themes forum!

 

In reply to Mary Evans

Re: Moodle Error : page layout file did not call $OUTPUT->doctype()

by Gopal Sharma -
Picture of Plugin developers Picture of Testers

First of all, please accept my apologies, For putting this issue in the developer forum instead theme. I request someone to please move this issue to theme forum.

I'm not using bootstrap as a base theme instead working on the development of a base theme.
In theme which I'm working on does not contain column2 layout and calling coulumn3 or column1 layout.
But when their column2 layout should be called, I'm calling column3 layout and postside-bar is appearing empty,
That is the reason I'm calling '$hasidepre' or '$hassidepost', only in those cases show the post or pre sidebar else hide them.


I hope that clear you doubt and even if it's not cleared let me know , I'll elaborate little more.

-Gopal 


In reply to Gopal Sharma

Re: Moodle Error : page layout file did not call $OUTPUT->doctype()

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

OK.

I have split your other comment in the Theme theme so you can work in there and leave the hyper-link back to this thread for reference as it is fixed for the question asked...OK?

Thanks

See you back here in the Themes forum

https://moodle.org/mod/forum/discuss.php?d=336739

Cheers

Mary