Override XenForo_ViewPublic_Helper_User::getUserFieldValueHtml

Codeless

Active member
Hello , I'm new to xenforo development and trying to Override XenForo_ViewPublic_Helper_User::getUserFieldValueHtml using existing tutorials with no success
this is my listener
Code:
class CustomField_Listener {
    public static function View($class, array &$extend)
    {  
	   if ($class == 'XenForo_ViewPublic_Helper_User')
            {
                $extend[] = 'CustomField_User';
            }
    }
}
it is set to load at load_class_view ..
and this code doesn't work
Code:
class CustomField_User extends XFCP_CustomField_User
{

    public function getUserFieldValueHtml(array $field, $value = null)
    {

	return  'TEST';
    }

}
any help would be appreciated
 
The short answer is that you can't extend/override static calls to methods. You would need to take a different approach. What sort of change are you trying to make?
 
I have custom field type 'attachment' and want to return attachment data instead of attachment id .. adding this code on getUserFieldValueHtml does the purpose ..
Code:
if ($field['field_id'] == 'medicalid') {
            $attachmentModel = XenForo_Model::create('XenForo_Model_Attachment');

        $attachments = $attachmentModel->getAttachmentsByContentId('custom_field', $value);

        if ($attachments) {
            $attachment = reset($attachments);
            $value = $attachmentModel->prepareAttachment($attachment);
        } else {
            $value = '';
        }

but I need to do this without editing files
 
You'll likely need to approach this differently if you want to do it without code edits. It may mean overriding the userfieldvalue template function entirely.

In terms of rendering, you'd need to figure out what your needs are. I'm not sure there's a standalone template that would necessarily fit your needs.
 
Top Bottom