Links in language strings?

Links in language strings?

by Ryan Holder -
Number of replies: 1

Hi All,

 

Can I put a link in a language srting. I tried normal html, but it didn't work - the whole string disappeared:

$string['notenrollable'] = 'This course is available to registered students only. Please click <a href="#">here</a> to register';

I also tried escaping the quotes with no effect:

$string['notenrollable'] = 'This course is available to registered students only. Please click <a href="/#"/>here</a> to register';

What do I need to do to get this working?

Many thanks

Ryan

Average of ratings: -
In reply to Ryan Holder

Re: Links in language strings?

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Yes, you can put the link into the string. That is pretty common. The question is what function you used to display the string. The following should work:

$string['foobar'] = 'Click <a href="{$a}">here</a>';

in the strings files and then

echo get_string('foobar', 'mymodule', 'http://foo.bar');