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

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

Discussion in 'Troubleshooting and Problems' started by Chris D, Feb 9, 2012.

  1. Chris D

    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.


    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.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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:


    Just guessing.
  3. Chris D

    Chris D XenForo Developer Staff Member

    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.

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    In the example.html file is this 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()) {
    		$('#gabe_adder').replaceWith('<div class="steamprofile" title="gabelogannewell"></div>');
    	/* ]]> */
    	<div id="gabe_adder"><a href="javascript:addGabe()">Add Gabe!</a></div>
    That is probably what you need.
  5. Chris D

    Chris D XenForo Developer Staff Member

    I have resolved this in another way.

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

    <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:foreach loop="$posts" value="$post">
    <html:hidden><style type="text/css">.extraUserInfo2 { display:none; }</style></html>
        <xen:include template="post" />
    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.
  6. Chris D

    Chris D XenForo Developer Staff Member


    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?
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

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


    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.
  8. Chris D

    Chris D XenForo Developer Staff Member

    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.

Share This Page