How to prevent the HTML editor appearing for certain pages? (Developer question)
How can I prevent the <textarea> from automagically turning into the HTML editor? It's highly inappropriate in the case of this particular form field...
Thanks in advance.
Re: How to prevent the HTML editor appearing for certain pages? (Developer question)
Hi Dan,
I wasn't aware of the HTML editor automatically turning every <textarea>
into a HTML editor.
If you use Moodle's print_textarea
function, the first argument specifies if you want to use the HTML editor (if the user has allowed it, that is)
print_textarea(false, 30, 65, 680, 400, "alltext", "default text");
will open a normal textarea with name 'alltext' and content 'default text'.
Re: How to prevent the HTML editor appearing for certain pages? (Developer question)
When I asked the question I was directly writing <textarea> to the page, and somehow that was automatically transformed into a HTML editor. Now, I'm doing as you say, with print_textarea(false...), and it still appears as a HTML editor! (I can prove that I'm looking at the right screen etc since if I manipulate the rows/cols arguments, the box changes size...)
Re: How to prevent the HTML editor appearing for certain pages? (Developer question)
The example is taken from the text
resource type, which AFAIK displays a normal <textarea>
... if I am looking at the right screen, that is...
Don't know why it doesn't work Maybe you could look at how the text
resource type displays a textarea without the HTML editor kicking in.
Re: How to prevent the HTML editor appearing for certain pages? (Developer question)
Set the *global* variable $usehtmleditor to 'summary' (i.e. the name(s) of the textarea(s) that you *do* want to be passed through the HTML editor) - if you don't do this, then by default all of the textareas are transformed.
Re: How to prevent the HTML editor appearing for certain pages? (Developer question)
usually used:
at the top of the page:
$usehtmleditor = can_use_html_editor();
and at the bottom of the page:
if ( $usehtmleditor ) {
use_html_editor();
}
So just leave these out and editor shouldn't appear.
- Janne -
Re: How to prevent the HTML editor appearing for certain pages? (Developer question)
This development is part of the "mod/resource" framework so perhaps something else somewhere is calling that function. But I've done a text search on the "mod/resource" folder and can't find a reference anywhere...
Re: How to prevent the HTML editor appearing for certain pages? (Developer question)
Dan,
I downloaded your jmol resource type, but couldn't find a textarea. Maybe you are referring to a new version you are working on.
$usehtmleditor
is set in course/mod.php before code of the mod/resource framework is called. It is set according to the user preference. (See function can_use_html_editor()
in moodlelib.php
)