XF 1.1 When using Quick Reply, Steam Profile badge doesn't render until refresh.

Chris D

XenForo developer
Staff member
You will have to forgive me as I am rather a novice with XenForo, but something is bugging me.

We have installed DarkImmortal's add on which displays a Steam Profile badge in the post bit and it works great.

However, when we use the Quick Reply when the post has been added to the thread, it doesn't have the Steam Profile badge as you can see from the attached image.

Difference.webp

Once the page is refreshed, everything appears normal.

It appears as though the steamprofile.js isn't called after that new post is added to the existing ones.

Currently steamprofile.js is called in the PAGE_CONTAINER template, but perhaps it also needs to be called elsewhere to ensure it is applied to new posts without requiring a refresh?

I have a similar problem elsewhere, but I think the answer to this, may solve that too.

Thank you for your help.
 
Can you post a link to that addon? I need to look at the code and see how it works.

If the addon fetches extra data for posts then maybe it is neglecting to fetch that data for this action as well:

XenForo_ControllerPublic_Thread::actionAddReply

Just guessing.
 
Hi Jake,

The link to the add-on is: http://xenforo.com/community/threads/steam-identity-service.9819/

EDIT: Oh and this http://code.google.com/p/steamprofile/ is the underlying platform that actually retrieves the data and creates the badge.

EDIT 2: I've just looked over some of the code, and the more I think about it, I do not believe DarkImmortal's add-on is the problem.

In the screenshot, the second post is exhibiting the same behaviour that happens if the steamprofile.js isn't loaded. If I were to remove that from the PAGE_CONTAINER template then all of the posts would exhibit the same problem: a plain URL just like in the new post in the screenshot.

That leads me to believe that when the new reply is added it doesn't see or load the script in the PAGE_CONTAINER template and instead the raw contents of that user profile field is displayed instead.

Chris
 
EDIT: Oh and this http://code.google.com/p/steamprofile/ is the underlying platform that actually retrieves the data and creates the badge.

In the example.html file is this code:

Code:
	<!--
	When other scripts insert a profile placeholder, you need to call the
	"refresh"-method of the SteamProfile object to replace the placeholders.
	-->
	<script type="text/javascript">
	/* <![CDATA[ */
	function addGabe() {
		// to avoid interferences, SteamProfile locks the loading of
		// other profiles until the current query is finished
		if(SteamProfile.isLocked()) {
			return;
		}
		
		$('#gabe_adder').replaceWith('<div class="steamprofile" title="gabelogannewell"></div>');
		SteamProfile.refresh();
	}
	/* ]]> */
	</script>
	<div id="gabe_adder"><a href="javascript:addGabe()">Add Gabe!</a></div>

That is probably what you need.
 
I have resolved this in another way.

I've added an inline style in the thread_reply_new_posts template:

HTML:
<xen:if is="{$firstUnshownPost}">
    <li class="newMessagesNotice">{xen:phrase there_more_posts_to_display} <a href="{xen:link posts, $firstUnshownPost}#post-{$firstUnshownPost.post_id}">{xen:phrase view_them}</a></li>
</xen:if>
<xen:foreach loop="$posts" value="$post">
<html:hidden><style type="text/css">.extraUserInfo2 { display:none; }</style></html>
    <xen:include template="post" />
</xen:foreach>

So actually when the new post is added, that content isn't shown at all. I have found absolutely no way at all to get the profile badge to render, so this plan B is the next best thing, and I'm happy with it.
 
OK.

I need a little help again.

I was actually able to solve the original problem and get the badge to show. The great news is, when a new post is added to the page it now displays properly.

The same cannot be said for when a post is edited though.

Can anyone explain: If it is the thread_reply_new_posts template which inserts a brand new post into a page after submitting it via the quick reply box, which template does a similar job after submitting an edit via the post inline edit overlay?
 
Can anyone explain: If it is the thread_reply_new_posts template which inserts a brand new post into a page after submitting it via the quick reply box, which template does a similar job after submitting an edit via the post inline edit overlay?

The response from an inline edit doesn't have a content template like the quick reply does. This is the controller for it:

XenForo_ControllerPublic_Thread::actionShowPosts

The return value does not specify a content template. Instead the view (XenForo_ViewPublic_Thread_ViewPosts::renderJson) builds the output directly using the post template.

You could extend the view with an addon to append your inline styling to the output. Or you could add it to the post template, but that may be overkill.
 
Thanks for the reply.

I've had a go at adding it to the post template. I have a feeling this would work, but it still doesn't see the javascript contained in the heading of the PAGE_CONTAINER template. So that would mean calling the javascript within the post template itself.

The problem with that, however, is the Quck Reply box disappears. I can only assume that calling a javascript 20+ times on one page does all sorts of things to break any other javascript on the page.

I am going to look at what I can do in terms of editing the view to see if I can achieve what I want with an add on.

Failing that, I might have another trick up my sleeve which will hide it.
 
Top Bottom