Custom author component not working on Post Page
I created this author component that works on all pages I've seen, except for on the post page. This is the error: https://www.dropbox.com/s/fqirqygr4uhg7ag/Screenshot%202014-02-23%2013.11.04.png
Does anyone know how to modify this code so that it works on the post page just like it does in the message listing? Thanks!
<#--Custom author component with new order: Avatar, rank, posts, kudos. Original author component XML is <component id="author"/> -->
<#assign messageAuthorId = rest("/messages/id/${page.context.message.uniqueId}/author").user.id />
<#assign messageAuthorLogin = rest("/messages/id/${page.context.message.uniqueId}/author").user.login />
<#assign avatarUrl = rest("/users/id/${messageAuthorId}/profiles/avatar/url").value />
<#assign kudosCount = rest("/users/id/${messageAuthorId}/kudos/received/count").value />
<#assign postCount = rest("/users/id/${messageAuthorId}/posts/count").value />
<#assign rankingName = rest("users/id/${messageAuthorId}/ranking/name").value />
<#assign profileUrl = "/t5/user/viewprofilepage/user-id/${messageAuthorId}" />
<div class="lia-message-author-avatar">
<div class="custom-avatar-wrapper">
<div class="UserAvatar lia-user-avatar lia-component-common-widget-user-avatar">
<a class="UserAvatar lia-link-navigation" tabindex="-1" target="_self" id="link_39" href="${profileUrl}"><img class="lia-user-avatar-message" id="display" src="${avatarUrl}"></a>
</div>
</div>
</div>
<div class="lia-message-author-username">
<span class="UserName lia-user-name">
<a class="lia-link-navigation lia-page-link lia-user-name-link" href="${profileUrl}">
<span class="">${messageAuthorLogin}</span>
</a>
</span>
</div>
<div class="lia-message-author-rank">${rankingName}</div>
<div class="lia-message-author-post-count" title="Number of posts by this author">
<table>
<tr><td class="fonticon"><i class="fa fa-comment"></i></td><td class="count">${postCount}</td></tr>
</table>
</div>
</tr>
<div class="lia-message-author-kudos-count" title="Number of votes received by this author">
<table>
<tr><td class="fonticon"><i class="fa fa-thumbs-up"></i></td><td class="count">${kudosCount}</td></tr>
</table>
</div>
Solved it--sort of. I test to see if the page is ReplyPage. If it is, I serve the default author component to avoid the error. If it's not, I serve the my custom author component.
Again, big thanks to Claudius-- I noticed he used the default author component on the reply page, too.
Here's the final code:
<#--Custom author component with new order: Avatar, rank, posts, kudos. Original author component XML is <component id="author"/>. On Reply page, defaults to Out-of-the-box author component. -->
<#if page.name?lower_case == "replypage" >
<@component id="author"/>
<#else>
<#assign messageAuthorId = rest("/messages/id/${page.context.message.uniqueId}/author").user.id />
<#assign messageAuthorLogin = rest("/messages/id/${page.context.message.uniqueId}/author").user.login />
<#assign avatarUrl = rest("/users/id/${messageAuthorId}/profiles/avatar/url").value />
<#assign kudosCount = rest("/users/id/${messageAuthorId}/kudos/received/count").value />
<#assign postCount = rest("/users/id/${messageAuthorId}/posts/count").value />
<#assign rankingName = rest("users/id/${messageAuthorId}/ranking/name").value />
<#assign profileUrl = "/t5/user/viewprofilepage/user-id/${messageAuthorId}" />
<div class="lia-message-author-avatar">
<div class="custom-avatar-wrapper">
<div class="UserAvatar lia-user-avatar lia-component-common-widget-user-avatar">
<a class="UserAvatar lia-link-navigation" tabindex="-1" target="_self" id="link_39" href="${profileUrl}"><img class="lia-user-avatar-message" id="display" src="${avatarUrl}"></a>
</div>
</div>
</div>
<div class="lia-message-author-username">
<span class="UserName lia-user-name">
<a class="lia-link-navigation lia-page-link lia-user-name-link" href="${profileUrl}">
<span class="">${messageAuthorLogin}</span>
</a>
</span>
</div>
<div class="lia-message-author-rank">${rankingName}</div>
<div class="lia-message-author-post-count" title="Number of posts by this author">
<table>
<tr><td class="fonticon"><i class="fa fa-comment"></i></td><td class="count">${postCount}</td></tr>
</table>
</div>
</tr>
<div class="lia-message-author-kudos-count" title="Number of votes received by this author">
<table>
<tr><td class="fonticon"><i class="fa fa-thumbs-up"></i></td><td class="count">${kudosCount}</td></tr>
</table>
</div>
</#if>