In Joomla's profile plugin, I came across these lines of code

if (!HTMLHelper::isRegistered('users.url'))
            HTMLHelper::register('users.url', array(__CLASS__, 'url'));

        if (!HTMLHelper::isRegistered('users.calendar'))
            HTMLHelper::register('users.calendar', array(__CLASS__, 'calendar'));

        if (!HTMLHelper::isRegistered('users.tos'))
            HTMLHelper::register('users.tos', array(__CLASS__, 'tos'));

        if (!HTMLHelper::isRegistered('users.dob'))
            HTMLHelper::register('users.dob', array(__CLASS__, 'dob'));

I checked Joomla API, but still don't quite get what HTMLHelper does. And it says isRegistered is to test if the key is registered - register where?


As far as I understand it, this is to allow developers to override the standard Joomla classes which output HTML elements. So if you don't like how Joomla outputs the "dob" element for capturing the user's date of birth, then you can define your own code for displaying it, and then in a plugin you can do:

 HTMLHelper::register('users.dob', array('myclass', 'my_dob'));

Joomla will then call your class function instead of its standard code.

The call to isRegistered() is just to check if some other plugin has done that - the registration is handled locally within HTMLHelper.

See Bakual's answer to What does JHtml::_ do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.