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

Help with Status update code

Discussion in 'XenForo Development Discussions' started by Jamie, Nov 21, 2010.

  1. Jamie

    Jamie Well-Known Member

    Ok, so I have converted my site and want to focus on the forums and it's options, so I have made the recent activity area my "home" page. (would be nice if I could get it to highlight the home tab instead of the member tab, but that's minor.)


    One thing I did was copy the status update box from the profile page and place it in the news feed box, which now shows up nicely on my front page.

    frontpage.png


    This only shows for registered members.

    It works, but when I enter the update the page doesn't automatically refresh like it does on the profile page. If you enter an update and then refresh the page or go to another page and come back, the new status update is there, it just doesn't do it 'cool like' the profile page.

    What did I miss to make this cool and smooth?

    Thanks!
    Jamie
     
    Trombones13 likes this.
  2. Jamie

    Jamie Well-Known Member

    By the way, here is what I did to add this:

    In the newsfeed template:

    Add this to the top of the template:

    Code:
    <xen:require js="js/xenforo/personal_details_editor.js" />
    
    Find:

    Code:
    <xen:if is="{$newsFeed}">
    
    Add this code above it:

    Code:
    <!-- Status Update on News Feed -->
    <xen:if is="{$visitor.user_id}">
    <form method="post" class="xenForm personalDetailsForm AutoValidator"
        action="{xen:link 'account/personal-details-save'}"
        data-fieldValidatorUrl="{xen:link 'account/validate-field.json'}">
    
        <dl class="ctrlUnit">
            <dt><label for="ctrl_status">{xen:phrase status_message}:</label></dt>
            <dd>
                <textarea name="status" rows="2" cols="60" id="ctrl_status" autofocus="autofocus" class="textCtrl StatusEditor Elastic OptOut" data-statusEditorCounter="#statusEditorCounter"></textarea>
                <span id="statusEditorCounter" title="{xen:phrase characters_remaining}"></span>
                <div class="explain"><h3 class="statusHeader">{xen:phrase current_status}:</h3> <span class="CurrentStatus"><xen:if is="{$visitor.status}">{xen:string censor, $visitor.status}<xen:else />({xen:phrase none})</xen:if></span><!--TODO: clearing--></div>
            </dd>
        </dl>
    
        <xen:if hascontent="true">
            <fieldset>
                <xen:contentcheck>
                    <xen:if is="{$canEditAvatar}">
                        <dl class="ctrlUnit avatarEditor">
                            <dt><label>{xen:phrase avatar}:</label></dt>
                            <dd>
                                <xen:avatar user="$visitor" size="m" class="OverlayTrigger" href="{xen:link account/avatar}" />
                                <p class="explain">{xen:phrase click_image_to_change_your_avatar}</p>
                            </dd>
                        </dl>
                    </xen:if>
                    
                    <xen:if is="{$canEditCustomTitle}">
                        <dl class="ctrlUnit">
                            <dt><label for="ctrl_custom_title">{xen:phrase custom_title}:</label></dt>
                            <dd>
                                <input type="text" name="custom_title" value="{$visitor.custom_title}" id="ctrl_custom_title" class="textCtrl" />
                                <p class="explain">{xen:phrase if_specified_replace_title_that_displays_under_name_in_posts}</p>
                            </dd>
                        </dl>
                    </xen:if>
                </xen:contentcheck>
            </fieldset>
        </xen:if>
        <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    </form>
    </xen:if>
    <br />
    
     
    Ranger375 and Blandt like this.
  3. Jeremy P

    Jeremy P Well-Known Member

    In your form tag, try adding the parameter:
    HTML:
    data-redirect="on"
     
  4. Jamie

    Jamie Well-Known Member

    Ok, I am not sure if I put it in the right place, but it didn't work. I added it to the end of the input type line. If that was wrong, can you tell me where to place it?

    Thanks for your help!
    Jamie

    Code:
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" / data-redirect="on">
    
     
  5. Nasr

    Nasr Well-Known Member

    i think it should be before the forward slash. Not sure though.
     
  6. Jeremy P

    Jeremy P Well-Known Member

    Try adding it to the form tag like this: :)
    HTML:
    <form method="post" class="xenForm personalDetailsForm AutoValidator"
        action="{xen:link 'account/personal-details-save'}"
        data-fieldValidatorUrl="{xen:link 'account/validate-field.json'}" data-redirect="on">
     
  7. Jamie

    Jamie Well-Known Member

    Hum, that didn't seem to work either.. this is one of those times where I miss I knew more than I do. :)

    Jamie
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    Doing a very quick check, it looks like you need bits of xenforo.js, around lines 1780 and 690.

    js.PNG
     
  9. Kier

    Kier XenForo Developer Staff Member

    What you're asking for is a fairly significant modification - you need to intercept the status message being posted by hooking in to the events fired by the XenForo.AutoValidator Javascript class and load the appropriate template - it's really not the kind of thing that can be covered in a reply here. You'll get some ideas about how all this works from the next video I'm going to post into the AJAX Developer Demo thread in 'Have You Seen...'.
     
    Trombones13 likes this.
  10. Jamie

    Jamie Well-Known Member

    Thanks guys for the help. I look forward to the next video... at some point it looks like I am going to learn to code/understand code which is a good thing. :)

    Thanks again!
    Jamie
     
  11. ArnyVee

    ArnyVee Well-Known Member

    Jamie, did you ever get this going?

    That approach (recent activity as 'homepage' with the status update at top) is the exact thing that I want on my next site.
     
  12. Jamie

    Jamie Well-Known Member

    Hey ArnyVee,

    I haven't gotten it working.. It's something I really need for me site as well, I am going to start looking for someone to hire to handle it for me I think.

    Jamie
     
  13. ArnyVee

    ArnyVee Well-Known Member

    I'd be happy to split the cost with you when you find someone. Keep me posted, please :)
     
  14. Jamie

    Jamie Well-Known Member

    ok, certainly will!
     
  15. ragtek

    ragtek Guest

    What do you exactly want?
    I haven't understand what you already have/what's missing.
     
  16. ArnyVee

    ArnyVee Well-Known Member

    Ragtek,

    When you update your status on the profile page, it automatically updates the status and displays it without a page refresh.

    What we are looking to do is to take the "Recent Activity" page and make it act the same way by adding the 'status update' field above the activity/updates and then making it automatically update without a page refresh.

    While we're at it, I'd like the ability to "like" or "comment" on each of the recent activity actions as well. :D
     
  17. ragtek

    ragtek Guest

  18. ArnyVee

    ArnyVee Well-Known Member

    LOL...that's the whole point. We want to have it work all "ajax-y" :D
     
  19. ragtek

    ragtek Guest

    Why do you use the avatar and customtitle code here?
     
  20. Jamie

    Jamie Well-Known Member

    That was me just messing around and testing out if I could get it working. I know almost nothing when it comes to coding so I was just copying a chunk of code and pasting it in.. which didn't work out well.

    ArnyTee is correct... like him I am looking for a way to get my members more active on the recent activity screen.. ideally what I would like is to mimic facebook with the quickness and ease of posting status updates and keeping people in the loop with life, and then for deeper discussions we would use our forums in place for this.

    I am tring to mesh together the best of both worlds... the facebook (post a lot of status updates to keep people involved with each other's lives) backed by the power of a forum where real discussions could be had.

    Make sense? I am really bad at describing what I ideally want sadly.. :(

    Jamie
     
    ArnyVee likes this.

Share This Page