Additional HTML

Additional HTML

by ahmad my -
Number of replies: 7

Hello Every one.

I am new to moodle. I have a added a code to the "within Head" section and my website came down. I am wondering how I can delete the code. I cannot reach my website now.


Site admin > Appearance > Additional HTML and I added to the "Within HEAD" section.

Average of ratings: -
In reply to ahmad my

Re: Additional HTML

by Ken Task -
Picture of Particularly helpful Moodlers

Usually a good idea to share what version of Moodle and what theme using for a question like this, but ... try this ...

In config.php file of your site, add a line:

$CFG->additionalhtmlhead='';

just above the line that shows:

require_once(__DIR__ . '/lib/setup.php');

To set additionalhtmlhead to nothing.

Then see if you can login and go to the admin area where you added it and remove via  Web interface.

'SoS', Ken

In reply to Ken Task

Re: Additional HTML

by ahmad my -
Thank you so much. It worked. I really appreciate it
In reply to ahmad my

Re: Additional HTML

by Ken Task -
Picture of Particularly helpful Moodlers

Glad to hear it.  Lesson learned???? Errant html in that location can/will cause WSoD (the 'white screen of death') cause Moodle Themes are inline ... applies to entire site and for all users.

So if one is gonna try again, check that the HTML has appropriate opening tags as well as matching closing tags.   Tip: never copy and paste from MS Word any HTML - not without running that html via tidy to clean up M$ junk html.

'SoS', Ken


In reply to Ken Task

Re: Additional HTML

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Nice fix - I was going to tell them to find it in the database - that is what I had to do when I broke my site with an a missing colon or something similar!!!
In reply to Emma Richardson

Re: Additional HTML

by Ken Task -
Picture of Particularly helpful Moodlers

The 'fix' provided by using the cfg.php tool in admin/cli/ - so credit goes to whomever thought of/wrote/maintains that script.

I now do this on every server:

cd code/admin/cli/

php cfg.php > allsettings.txt

The hardest part of 'fixing' something in moodle config.php is learning the 'variablename'.   If one kinda knows what one is looking for, this works:

php cfg.php |grep additional

Pulls any/all settings that have 'additional' in 'short name'.

Above command displays:

additionalhtmlhead   
additionalhtmltopofbody   
additionalhtmlfooter

Above from a site that has no additional html inserted.

To 'blank':

$CFG->additionalhtmlhead='';

in config.php file.   No reboot nor restart required, just access with browser.

In some cases, such as OP's problem with WSOD, brings site back into view and enables admin to find/edit/change the errant setting.

After the addition to config.php has done it's job, can comment it out by putting // in front of that line, for the next time one messes up! smile

Once again, it does illustrate that having CLI access to a Moodle server is a very big plus in administering.  That's a biggy in choosing where/how to host a Moodle, IMHO! smile

'SoS', Ken


In reply to Ken Task

Re: Additional HTML

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Thanks, Ken, I learned something new.  😀
In reply to Rick Jerz

Re: Additional HTML

by Ken Task -
Picture of Particularly helpful Moodlers

Welcome!  With every new version of Moodle there is always something new to learn.  With every new version of Moodle, seems to me that more and more CLI only scripts are created.  They are there for a reason.

Here's something else I do with each new version ... find any cli directory so I can see/explore purpose and decide if they would be useful in admin of a server to which one has cli access:

find ./ -name cli

In the code directory of a 310 renders:

.//auth/cas/cli
.//auth/ldap/cli
.//auth/db/cli
.//admin/cli
.//admin/tool/behat/cli
.//admin/tool/dbtransfer/cli
.//admin/tool/generator/cli
.//admin/tool/phpunit/cli
.//admin/tool/uploaduser/cli
.//admin/tool/task/cli
.//admin/tool/httpsreplace/cli
.//admin/tool/replace/cli
.//admin/tool/uploadcourse/cli
.//admin/tool/analytics/cli
.//admin/tool/customlang/cli
.//enrol/database/cli
.//enrol/category/cli
.//enrol/flatfile/cli
.//enrol/meta/cli
.//enrol/cohort/cli
.//enrol/manual/cli
.//enrol/self/cli
.//enrol/paypal/cli
.//search/cli
.//theme/boost/cli
.//lib/classes/local/cli
.//lib/editor/tinymce/cli

SoS. Ken