Output author's avatar in quote

CyberAP

Well-known member
Is it possible to output author's avatar in quote by modifing template bb_code_tag_quote?
I couldn't find there a variable of authors user ID.
 
I couldn't find there a variable of authors user ID.
You can find this by that way:
1. See, where this template loading. I found it in library/XenForo/BbCode/Formatter/Base.php. And in file I found:
PHP:
                if ($this->_view)
                {
                        $template = $this->_view->createTemplateObject('bb_code_tag_quote', array(
                                'content' => $content,
                                'nameHtml' => $name,
                                'source' => $source,
                                'attributes' => $attributes,
                                'ignored' => (isset($attributes['member']) && isset($this->_ignoredUsers[intval($attributes['member'])]))
                        ));
                        return $template->render();
                }
                else
                {
                        return $this->_renderTagQuoteFallback($name, $content);
                }
2. Now we can try to interpose into a template I will give the necessary variables:
HTML:
<div>{xen:helper dump, $attributes}</div>

Result (for example) in quote area:
Code:
array
  'post' => string '109200' (length=6)
  'member' => string '823' (length=3)

It is all :)
 
This is really nice, but I wanted to do it without any addons. :)

Actually there is an array $source but I don't know if there is user id within it.
 
This is really nice, but I wanted to do it without any addons. :)
Actually there is an array $source but I don't know if there is user id within it.
Hm... But unless the variable {$attributes.member} is not that which you search?
Code:
[quote="CyberAP, post: 297468, member: 1756"]
HTML:
<div>{$attributes.member}</div>
is output 1756 in template
 
Yes! Thanks! That worked, but I get an error:

Code:
Template Errors: bb_code_tag_quote
Argument 1 passed to XenForo_Template_Helper_Core::helperAvatarHtml() must be an array, string given in /library/XenForo/Template/Helper/Core.php, line 1534
Argument 1 passed to XenForo_Template_Helper_Core::getUserHref() must be an array, string given, called in /library/XenForo/Template/Helper/Core.php on line 1562 and defined in /library/XenForo/Template/Helper/Core.php, line 1396
Template Errors: bb_code_tag_quote
Argument 1 passed to XenForo_Template_Helper_Core::helperAvatarHtml() must be an array, string given in /library/XenForo/Template/Helper/Core.php, line 1534
Argument 1 passed to XenForo_Template_Helper_Core::getUserHref() must be an array, string given, called in /library/XenForo/Template/Helper/Core.php on line 1562 and defined in /library/XenForo/Template/Helper/Core.php, line 1396

That avatar is displayed.
 
From template 'member_card'
HTML:
            <img src="{xen:helper avatar, {$user}, l}" alt="" style="{xen:helper avatarCropCss, $user}" />
where $user is must be array with two elements: $user.usr_id and $user.username.
Don't know how it's make.
 
I don't understand why the user name is needed when it can be found using user id.
So that means that <xen:avatar /> or {xen:helper avatar} can not be used here.
Since we can't set arrays in templates it is not possible to complete my task. :(
Thanks for the help!
 
With the help of infis and Pepelac almost finished it. But it has no support of gravatar and always shows the first avatar you've set in your profile.

PHP:
<xen:set var="$avaUser.user_id">{xen:number $attributes.member}</xen:set>
<xen:set var="$avaUser.username">{$nameHtml}</xen:set>
<xen:set var="$avaUser.gravatar">0</xen:set>
<xen:set var="$avaUser.avatar_date">1</xen:set>
 
<xen:avatar user="$avaUser" size="s" />
 
Top Bottom