Disable auto-linking filter during a call to format_text()/format_string()

Disable auto-linking filter during a call to format_text()/format_string()

by Michael Milette -
Number of replies: 3
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Moodle developers,

I was wondering if someone might be able to suggest a way to temporarily disable the auto-linking filters while I make my own calls to format_string() or format_text().

In particular, I would like to accomplish is to temporarily disable the auto-linking plugin including Activity names, Glossary and Database auto-linking filters as these find strings and turns them into links which is undesirable in my case since I am doing the same. However, I don't want to turn off these globally in case people actually want to use these, just for one or two calls to the format_....() functions.

I am attempting to do this from within a theme where I have full control of the source code.

Any suggestions?

Best regards,

Michael

Average of ratings: -
In reply to Michael Milette

Re: Disable auto-linking filter during a call to format_text()/format_string()

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is possible in recent Moodle versions. See MDL-50491 which I implemented because we needed this at the OU.

(Oops! just noticed that still has the dev docs required tag. However, I think the PHPdocs I wrote in the code are pretty good.)

Average of ratings: Useful (2)
In reply to Tim Hunt

Re: Disable auto-linking filter during a call to format_text()/format_string()

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Tim,

Thank you very much. Sound exactly like what I need. Can't wait to try it out.

Best regards,

Michael

In reply to Tim Hunt

Re: Disable auto-linking filter during a call to format_text()/format_string()

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hey Tim,

Just wanted to thank you again. I implemented your suggestion and it worked out perfectly. Thank you so much for putting in the effort to add support for this feature in Moodle core.

Have a great weekend!

Michael

Average of ratings: Useful (1)