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

XF 1.4 Issue with "Top" modification

Biker

Well-known member
#1
In the "post" template, I have this line added so the "Top" link appears after Reply on each post.

Code:
            &nbsp&nbsp&nbsp<a href="{$requestPaths.requestUri}#navigation" class="topLink">{xen:phrase go_to_top}</a>
For the most part, it works wonderfully and my users love it.

However, if you edit a post, and then click on the Top link, it results in an error.

This action is available via POST only. Please press the back button and try again.

Is there a way to prevent this from happening?
 

Dylan V

Well-known member
#2
In the "post" template, I have this line added so the "Top" link appears after Reply on each post.

Code:
            &nbsp&nbsp&nbsp<a href="{$requestPaths.requestUri}#navigation" class="topLink">{xen:phrase go_to_top}</a>
For the most part, it works wonderfully and my users love it.

However, if you edit a post, and then click on the Top link, it results in an error.

This action is available via POST only. Please press the back button and try again.

Is there a way to prevent this from happening?
Hi,

Your code is incorrect. Search for "post" template and replace this code:
Code:
            <div class="publicControls">
                <a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="item muted postNumber hashPermalink OverlayTrigger" data-href="{xen:link posts/permalink, $post}">#{xen:calc '{$post.position} + 1'}</a>
                <xen:hook name="post_public_controls" params="{xen:array 'post={$post}'}">
                <xen:if is="{$post.canLike}">
                    <a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
                </xen:if>
                <xen:if is="{$canReply}">
                    <xen:if is="{$xenOptions.multiQuote}"><a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}"
                        data-messageid="{$post.post_id}"
                        class="MultiQuoteControl JsOnly item control"
                        title="{xen:phrase toggle_multi_quote_tooltip}"><span></span><span class="symbol">{xen:phrase multiquote_add}</span></a></xen:if>
                    <a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}"
                        data-postUrl="{xen:link posts/quote, $post}"
                        data-tip="#MQ-{$post.post_id}"
                        class="ReplyQuote item control reply"
                        title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
                </xen:if>
                </xen:hook>
            </div>
with this:
Code:
            <div class="publicControls">
                <a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="item muted postNumber hashPermalink OverlayTrigger" data-href="{xen:link posts/permalink, $post}">#{xen:calc '{$post.position} + 1'}</a>
                <xen:hook name="post_public_controls" params="{xen:array 'post={$post}'}">
                <xen:if is="{$post.canLike}">
                    <a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
                </xen:if>
                <xen:if is="{$canReply}">
                    <xen:if is="{$xenOptions.multiQuote}"><a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}"
                        data-messageid="{$post.post_id}"
                        class="MultiQuoteControl JsOnly item control"
                        title="{xen:phrase toggle_multi_quote_tooltip}"><span></span><span class="symbol">{xen:phrase multiquote_add}</span></a></xen:if>
                    <a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}"
                        data-postUrl="{xen:link posts/quote, $post}"
                        data-tip="#MQ-{$post.post_id}"
                        class="ReplyQuote item control reply"
                        title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
                </xen:if>
                </xen:hook>
                <a href="{$requestPaths.requestUri}#navigation" style="margin-left: 10px;">{xen:phrase go_to_top}</a>
            </div>
Result:

Screenshot_1.png

To also display it in conversations, search for "conversation_message" template and replace this:
Code:
            <div class="publicControls">
                <xen:contentcheck>
                    <xen:hook name="conversation_message_public_controls" params="{xen:array 'message={$message}'}">
                    <xen:if is="{$canReplyConversation}">
                        <a href="{xen:link 'conversations/reply', $conversation, 'm={$message.message_id}'}"
                            class="item control reply ReplyQuote"><span></span>{xen:phrase reply}</a>
                    </xen:if>
                    </xen:hook>
                </xen:contentcheck>
            </div>
with this:
Code:
            <div class="publicControls">
                <xen:contentcheck>
                    <xen:hook name="conversation_message_public_controls" params="{xen:array 'message={$message}'}">
                    <xen:if is="{$canReplyConversation}">
                        <a href="{xen:link 'conversations/reply', $conversation, 'm={$message.message_id}'}"
                            class="item control reply ReplyQuote"><span></span>{xen:phrase reply}</a>
                    </xen:if>
                    </xen:hook>
                    <a href="{$requestPaths.requestUri}#navigation" style="margin-left: 10px;">{xen:phrase go_to_top}</a>
                </xen:contentcheck>
            </div>
Result:

Screenshot_2.png
 

Biker

Well-known member
#3
I made the change and put it outside the conditional in the template and still ended up with the error after an edit.
 

Dylan V

Well-known member
#4
I made the change and put it outside the conditional in the template and still ended up with the error after an edit.
Try to replace the "post" template with:
Code:
<xen:include template="message">

    <xen:map from="$post" to="$message" />

    <xen:set var="$messageId">post-{$post.post_id}</xen:set>
   
    <xen:set var="$likesUrl">{xen:link posts/likes, $post}</xen:set>
   
    <xen:set var="$messageContentAfterTemplate"><xen:if is="{$post.attachments}"><xen:include template="attached_files" /></xen:if></xen:set>
   
    <xen:set var="$messageAfterTemplate">
               
        <div class="messageMeta ToggleTriggerAnchor">
           
            <div class="privateControls">
                <xen:if is="{$post.canInlineMod}"><input type="checkbox" name="posts[]" value="{$post.post_id}" class="InlineModCheck item" data-target="#post-{$post.post_id}" title="{xen:phrase select_this_post_by_x, 'name={$post.username}'}" /></xen:if>
                <span class="item muted">
                    <span class="authorEnd"><xen:username user="$post" class="author" />,</span>
                    <a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="datePermalink"><xen:datetime time="$post.post_date" /></a>
                </span>
                <xen:hook name="post_private_controls" params="{xen:array 'post={$post}'}">
                <xen:if is="{$post.canEdit}">
                    <a href="{xen:link posts/edit, $post}" class="item control edit {xen:if $xenOptions.messageInlineEdit, OverlayTrigger}"
                        data-href="{xen:link posts/edit-inline, $post}" data-overlayOptions="{&quot;fixed&quot;:false}"
                        data-messageSelector="#post-{$post.post_id}"><span></span>{xen:phrase edit}</a>
                    <xen:require js="js/xenforo/discussion.js" />
                </xen:if>
                <xen:if is="{$post.edit_count} && {$post.canViewHistory}"><a href="{xen:link posts/history, $post}" class="item control history ToggleTrigger"><span></span>{xen:phrase history}</a></xen:if>
                <xen:if is="{$post.canDelete}"><a href="{xen:link posts/delete, $post}" class="item control delete OverlayTrigger"><span></span>{xen:phrase delete}</a></xen:if>
                <xen:if is="{$post.canCleanSpam}"><a href="{xen:link spam-cleaner, $post}" class="item control deleteSpam OverlayTrigger"><span></span>{xen:phrase spam}</a></xen:if>
                <xen:if is="{$canViewIps} AND {$post.ip_id}"><a href="{xen:link posts/ip, $post}" class="item control ip OverlayTrigger"><span></span>{xen:phrase ip}</a></xen:if>
               
                <xen:if is="{$post.canWarn}">
                    <a href="{xen:link members/warn, $post, 'content_type=post', 'content_id={$post.post_id}'}" class="item control warn"><span></span>{xen:phrase warn}</a>
                <xen:elseif is="{$post.warning_id} && {$canViewWarnings}" />
                    <a href="{xen:link warnings, $post}" class="OverlayTrigger item control viewWarning"><span></span>{xen:phrase view_warning}</a>
                </xen:if>
                <xen:if is="{$post.canReport}">
                    <a href="{xen:link posts/report, $post}" class="OverlayTrigger item control report" data-cacheOverlay="false"><span></span>{xen:phrase report}</a>
                </xen:if>
               
                </xen:hook>
            </div>
           
            <div class="publicControls">
                <a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="item muted postNumber hashPermalink OverlayTrigger" data-href="{xen:link posts/permalink, $post}">#{xen:calc '{$post.position} + 1'}</a>
                <xen:hook name="post_public_controls" params="{xen:array 'post={$post}'}">
                <xen:if is="{$post.canLike}">
                    <a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
                </xen:if>
                <xen:if is="{$canReply}">
                    <xen:if is="{$xenOptions.multiQuote}"><a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}"
                        data-messageid="{$post.post_id}"
                        class="MultiQuoteControl JsOnly item control"
                        title="{xen:phrase toggle_multi_quote_tooltip}"><span></span><span class="symbol">{xen:phrase multiquote_add}</span></a></xen:if>
                    <a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}"
                        data-postUrl="{xen:link posts/quote, $post}"
                        data-tip="#MQ-{$post.post_id}"
                        class="ReplyQuote item control reply"
                        title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
                </xen:if>
                </xen:hook>
                <a href="{$requestPaths.requestUri}#navigation" style="margin-left: 10px;">{xen:phrase go_to_top}</a>
            </div>
        </div>
    </xen:set>
   
</xen:include>
and the "conversation_message" template with:
Code:
<xen:include template="message">
   
    <xen:set var="$messageId">message-{$message.message_id}</xen:set>
   
    <xen:set var="$messageContentAfterTemplate"><xen:if is="{$message.attachments}"><xen:include template="attached_files">
        <xen:map from="$message" to="$post" /></xen:include></xen:if></xen:set>
   
    <xen:set var="$messageAfterTemplate">
        <div class="messageMeta">
            <div class="privateControls">
                <span class="item muted"><xen:username user="$message" class="author" />,
                    <a href="{xen:link conversations/message, $conversation, 'message_id={$message.message_id}'}" class="datePermalink"><xen:datetime time="$message.message_date" /></a>
                </span>
                <xen:hook name="conversation_message_private_controls" params="{xen:array 'message={$message}'}">
                <xen:if is="{$message.canEdit}">
                    <a href="{xen:link 'conversations/edit-message', $conversation, 'm={$message.message_id}'}"
                        class="item control edit {xen:if $xenOptions.messageInlineEdit, OverlayTrigger}"
                        data-overlayOptions="{&quot;fixed&quot;:false}"
                        data-href="{xen:link conversations/edit-message-inline, $conversation, 'm={$message.message_id}'}"
                        data-messageSelector="#message-{$message.message_id}"><span></span>{xen:phrase edit}</a>
                    <xen:require js="js/xenforo/discussion.js" />
                </xen:if>
                <xen:if is="{$message.canReport}">
                    <a href="{xen:link 'conversations/report', $conversation, 'message_id={$message.message_id}'}" class="OverlayTrigger item control report" data-cacheOverlay="false"><span></span>{xen:phrase report}</a>
                </xen:if>
                </xen:hook>
            </div>
           
            <xen:if hascontent="true">
            <div class="publicControls">
                <xen:contentcheck>
                    <xen:hook name="conversation_message_public_controls" params="{xen:array 'message={$message}'}">
                    <xen:if is="{$canReplyConversation}">
                        <a href="{xen:link 'conversations/reply', $conversation, 'm={$message.message_id}'}"
                            class="item control reply ReplyQuote"><span></span>{xen:phrase reply}</a>
                    </xen:if>
                    </xen:hook>
                    <a href="{$requestPaths.requestUri}#navigation" style="margin-left: 10px;">{xen:phrase go_to_top}</a>
                </xen:contentcheck>
            </div>
            </xen:if>
        </div>
    </xen:set>
   
</xen:include>