• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Override XenForo_ViewPublic_Helper_User::getUserFieldValueHtml

Codeless

Active member
#1
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
 

Mike

XenForo developer
Staff member
#2
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?
 

Codeless

Active member
#3
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
 

Mike

XenForo developer
Staff member
#5
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.