What's Wrong With My Thread View Template?

TheBigK

Well-known member
I've the following thread view template already working on the site. However, when I simply click on 'Save All Changes' button; I get "Internal Server Error" message. That makes me wonder -> if there are errors on the page; why did it not throw any message when I saved it in the past and what's going wrong with it right now?

Splitting the template into two posts (10000 words limit)

PHP:
<xen:title>{xen:helper threadPrefix, $thread, escaped}{$thread.title}{xen:helper pagenumber, $page}</xen:title>
<xen:h1>{xen:helper threadPrefix, $thread}{$thread.title}</xen:h1>
 
<xen:description>
    {xen:phrase discussion_in_x_started_by_y_date_z,
        'forum=<a href="{xen:link forums, $forum}">{$forum.title}</a>',
        'name={xen:helper username, $thread}',
        'date=<a href="{xen:link threads, $thread}">{xen:datetime $thread.post_date, html}</a>'}
</xen:description>
 
<xen:navigation>
    <xen:breadcrumb source="$nodeBreadCrumbs" />
</xen:navigation>
 
<xen:container var="$head.canonical">
    <link rel="canonical" href="{xen:link 'canonical:threads', $thread, 'page={$page}'}" /></xen:container>
<xen:container var="$head.description">
    <meta name="description" content="{xen:helper snippet, $firstPost.message, 155}" /></xen:container>
<xen:container var="$head.openGraph"><xen:include template="open_graph_meta">
        <xen:set var="$url">{xen:link 'canonical:threads', $thread}</xen:set>
        <xen:set var="$title">{xen:helper threadPrefix, $thread, escaped}{$thread.title}</xen:set>
        <xen:set var="$avatar">{xen:helper avatar, $thread, m, 0, 1}</xen:set>
    </xen:include></xen:container>
<xen:container var="$bodyClasses">{xen:helper nodeClasses, $nodeBreadCrumbs, $forum}</xen:container>
<xen:container var="$searchBar.thread"><xen:include template="search_bar_thread_only" /></xen:container>
<xen:container var="$searchBar.forum"><xen:include template="search_bar_forum_only" /></xen:container>
 
<xen:if is="{$canReply}">
    <xen:comment><xen:topctrl>
        <a href="{xen:link 'threads/reply', $thread}" class="callToAction"><span>{xen:phrase reply_to_thread}</span></a>
    </xen:topctrl></xen:comment>
</xen:if>
 
<xen:require css="thread_view.css" />
 
<xen:edithint template="message" />
 
<xen:if is="{$poll}">
    <xen:include template="poll_block">
        <xen:set var="$options">
            <xen:if is="{$poll.canVote}">
                <xen:include template="poll_block_vote" />
            <xen:else />
                <xen:include template="poll_block_result" />
            </xen:if>
        </xen:set>
    </xen:include>
</xen:if>
 
<xen:if is="{$showPostedNotice}">
    <div class="importantMessage">{xen:phrase message_submitted_displayed_pending_approval}</div>
</xen:if>
 
<xen:set var="$threadStatusHtml">
    <xen:if hascontent="true">
        <dl class="threadAlerts secondaryContent">
            <dt>{xen:phrase thread_status}:</dt>
            <xen:contentcheck>
                <xen:if is="{$thread.discussion_state} == 'deleted'">
                    <dd class="deletedAlert">
                        <span class="icon Tooltip" title="{xen:phrase deleted}" data-tipclass="iconTip"></span>
                            {xen:phrase removed_from_public_view}</dd>
                <xen:elseif is="{$thread.discussion_state} == 'moderated'" />
                    <dd class="moderatedAlert">
                        <span class="icon Tooltip" title="{xen:phrase awaiting_moderation}" data-tipclass="iconTip"></span>
                            {xen:phrase awaiting_moderation_before_being_displayed_publicly}</dd>
                </xen:if>
   
                <xen:if is="!{$thread.discussion_open}">
                    <dd class="lockedAlert">
                        <span class="icon Tooltip" title="{xen:phrase locked}" data-tipclass="iconTip"></span>
                            {xen:phrase not_open_for_further_replies}</dd>
                </xen:if>
            </xen:contentcheck>
        </dl>
    </xen:if>
</xen:set>
{xen:raw $threadStatusHtml}
 
<xen:hook name="thread_view_pagenav_before" params="{xen:array 'thread={$thread}'}" />
 
<div class="pageNavLinkGroup">
    <div class="linkGroup SelectionCountContainer">
        <xen:if hascontent="true">
            <div class="Popup">
                <a rel="Menu">{xen:phrase thread_tools}</a>
                <div class="Menu">
                    <div class="primaryContent menuHeader"><h3>{xen:phrase thread_tools}</h3></div>
                    <ul class="secondaryContent blockLinksList">
                        <xen:contentcheck>
                            <xen:if is="{$canEditThread}">
                                <li><a href="{xen:link 'threads/edit', $thread}" class="OverlayTrigger">{xen:phrase edit_thread}</a></li>
                            </xen:if>
                            <xen:if is="{$canDeleteThread}">
                                <li><a href="{xen:link 'threads/delete', $thread}" class="OverlayTrigger">{xen:phrase delete_thread}</a></li>
                            </xen:if>
                            <xen:if is="{$canMoveThread}">
                                <li><a href="{xen:link 'threads/move', $thread}" class="OverlayTrigger">{xen:phrase move_thread}</a></li>
                            </xen:if>
                            <xen:if is="{$deletedPosts}">
                                <li><a href="{xen:link threads/show-posts, $thread, 'page={$page}'}" class="MessageLoader" data-messageSelector="#messageList .message.deleted.placeholder">{xen:phrase show_deleted_posts}</a></li>
                            </xen:if>
                        </xen:contentcheck>
                    </ul>
                    <xen:if hascontent="true">
                    <form action="{xen:link threads/quick-update, $thread}" method="post" class="AutoValidator">
                        <ul class="secondaryContent blockLinksList checkboxColumns">
                        <xen:contentcheck>
                            <xen:if is="{$canLockUnlockThread}">
                            <li><label><input type="checkbox" name="discussion_open" value="1" class="SubmitOnChange" {xen:checked $thread.discussion_open} />
                                {xen:phrase open_thread}</label>
                                <input type="hidden" name="set[discussion_open]" value="1" /></li></xen:if>
                            <xen:if is="{$canStickUnstickThread}">
                            <li><label><input type="checkbox" name="sticky" value="1" class="SubmitOnChange" {xen:checked $thread.sticky} />
                                {xen:phrase sticky}</label>
                                <input type="hidden" name="set[sticky]" value="1" /></li></xen:if>
                        </xen:contentcheck>
                        </ul>
                        <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
                    </form>
                    </xen:if>
                    <xen:if is="{$thread.canInlineMod}">
                    <form action="{xen:link inline-mod/thread/switch}" method="post" class="InlineModForm sectionFooter" id="threadViewThreadCheck"
                        data-cookieName="threads">
                        <label><input type="checkbox" name="threads[]" value="{$thread.thread_id}" class="InlineModCheck" /> {xen:phrase select_for_thread_moderation}</label>
                        <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
                    </form>
                    </xen:if>
                </div>
            </div>
        </xen:if>
        <xen:if is="{$canWatchThread}">
            <a href="{xen:link 'threads/watch-confirm', $thread}" class="OverlayTrigger" data-cacheOverlay="false">{xen:if $thread.thread_is_watched, '{xen:phrase unwatch_thread}', '{xen:phrase watch_thread}'}</a>
        </xen:if>
    </div>
 
    <xen:pagenav link="threads" linkdata="{$thread}"
        page="{$page}" perpage="{$postsPerPage}" total="{$totalPosts}"
        unreadlink="{$unreadLink}" />
</div>
 
PHP:
<xen:include template="ad_thread_view_above_messages" />
 
<xen:hook name="thread_view_form_before" params="{xen:array 'thread={$thread}'}" />
 
<form action="{xen:link 'inline-mod/post/switch'}" method="post"
    class="InlineModForm section"
    data-cookieName="posts"
    data-controls="#InlineModControls"
    data-imodOptions="#ModerationSelect option">
 
    <ol class="messageList" id="messageList">
        <xen:foreach loop="$posts" value="$post">
            <xen:if is="{$post.message_state} == 'deleted'">
                <xen:include template="post_deleted_placeholder" />
            <xen:else />
                <xen:include template="post" />
            </xen:if>
        </xen:foreach>
        <xen:edithint template="attached_files" />
    </ol>
 
    <xen:if is="{$inlineModOptions}">
        <div class="sectionFooter InlineMod Hide">
            <label for="ModerationSelect">{xen:phrase perform_action_with_selected_posts}...</label>
 
            <xen:include template="inline_mod_controls">
                <xen:set var="$text">{xen:phrase post_moderation}</xen:set>
                <xen:set var="$options">
                    <xen:if is="{$inlineModOptions.delete}"><option value="delete">{xen:phrase delete_posts}...</option></xen:if>
                    <xen:if is="{$inlineModOptions.undelete}"><option value="undelete">{xen:phrase undelete_posts}</option></xen:if>
                    <xen:if is="{$inlineModOptions.approve}"><option value="approve">{xen:phrase approve_posts}</option></xen:if>
                    <xen:if is="{$inlineModOptions.unapprove}"><option value="unapprove">{xen:phrase unapprove_posts}</option></xen:if>
                    <xen:if is="{$inlineModOptions.move}"><option value="move">{xen:phrase move_posts}...</option></xen:if>
                    <xen:if is="{$inlineModOptions.merge}"><option value="merge">{xen:phrase merge_posts}...</option></xen:if>
                    <option value="deselect">{xen:phrase deselect_posts}</option>
                </xen:set>
                <xen:set var="$checkboxTitle">{xen:phrase select_deselect_all_posts_on_this_page}</xen:set>
                <xen:set var="$selectedItemsPhrase">{xen:phrase selected_posts}</xen:set>
            </xen:include>
        </div>
    </xen:if>
 
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
 
</form>
 
<xen:if hascontent="true">
    <div class="pageNavLinkGroup">
        <xen:contentcheck>
            <xen:if is="{$canQuickReply}">
                <xen:if is="{$postsRemaining}">
                    <div class="linkGroup">
                        <xen:if is="{$postsRemaining} == 1">
                            <a href="{xen:link threads, $thread, 'page={xen:calc "{$page} + 1"}'}" class="postsRemaining">{xen:phrase 1_more_message}...</a>
                        <xen:else />
                            <a href="{xen:link threads, $thread, 'page={xen:calc "{$page} + 1"}'}" class="postsRemaining">{xen:phrase x_more_messages, 'count={xen:number $postsRemaining}'}...</a>
                        </xen:if>
                    </div>
                </xen:if>
            <xen:else />
                <div class="linkGroup">
                    <xen:if is="{$canReply}">
                        <a href="{xen:link 'threads/reply', $thread}" class="callToAction"><span>{xen:phrase reply_to_thread}</span></a>
                    <xen:elseif is="{$visitor.user_id}" />
                        ({xen:phrase no_permission_to_reply})
                    <xen:else />
                        <label for="LoginControl"><a href="{xen:link login}" class="concealed">({xen:phrase log_in_or_sign_up_to_reply})</a></label>
                    </xen:if>
                </div>
            </xen:if>
            <div class="linkGroup"{xen:if '!{$ignoredNames}', ' style="display: none"'}><a href="javascript:" class="muted jsOnly DisplayIgnoredContent Tooltip" title="{xen:phrase show_hidden_content_by_x, "names={xen:helper implode, $ignoredNames, ', '}"}">{xen:phrase show_ignored_content}</a></div>
 
            <xen:pagenav link="threads" linkdata="{$thread}"
                page="{$page}" perpage="{$postsPerPage}" total="{$totalPosts}"
                unreadlink="{$unreadLink}"
            />
        </xen:contentcheck>
    </div>
</xen:if>
 
<xen:include template="ad_thread_view_below_messages" />
 
<xen:hook name="thread_view_qr_before" params="{xen:array 'thread={$thread}'}" />
 
<xen:if is="{$canQuickReply}">
    <xen:include template="quick_reply">
        <xen:set var="$formAction">{xen:link 'threads/add-reply', $thread}</xen:set>
        <xen:set var="$lastDate">{$lastPost.post_date}</xen:set>
        <xen:set var="$showMoreOptions">1</xen:set>
    </xen:include>
</xen:if>
 
<xen:hook name="thread_view_qr_after" params="{xen:array 'thread={$thread}'}" />
 
{xen:raw $threadStatusHtml}
 
<xen:include template="share_page">
    <xen:set var="$url">{xen:link 'canonical:threads', $thread}</xen:set>
</xen:include>
 
The 'Message' template looks RED when I open the thread_view template. Here's how it looks:-

PHP:
<xen:require css="message.css" />
<xen:require css="bb_code.css" />
 
<li id="{$messageId}" class="message {xen:if $message.isDeleted, 'deleted'} {xen:if '{$message.is_admin} OR {$message.is_moderator}', 'staff'} {xen:if $message.isIgnored, ignored}" data-author="{$message.username}">
    <xen:include template="message_user_info">
        <xen:map from="$message" to="$user" />
    </xen:include>
 
    <div class="messageInfo primaryContent">
        <xen:if is="{$message.isNew}"><strong class="newIndicator"><span></span>{xen:phrase new}</strong></xen:if>
       
        <xen:if hascontent="true">
            <ul class="messageNotices">
                <xen:contentcheck>
                    <xen:hook name="message_notices" params="{xen:array 'message={$message}'}">
                        <xen:if is="{$message.warning_message}">
                            <li class="warningNotice"><span class="icon Tooltip" title="{xen:phrase warning}" data-tipclass="iconTip flipped"></span>{$message.warning_message}</li>
                        </xen:if>
                        <xen:if is="{$message.isDeleted}">
                            <li class="deletedNotice"><span class="icon Tooltip" title="{xen:phrase deleted}" data-tipclass="iconTip flipped"></span>{xen:phrase this_message_has_been_removed_from_public_view}</li>
                        <xen:elseif is="{$message.isModerated}" />
                            <li class="moderatedNotice"><span class="icon Tooltip" title="{xen:phrase awaiting_moderation}" data-tipclass="iconTip flipped"></span>{xen:phrase this_message_is_awaiting_moderator_approval_and_is_invisible_to_normal}</li>
                        </xen:if>
                        <xen:if is="{$message.isIgnored}">
                            <li>{xen:phrase you_are_ignoring_content_by_this_member} <a href="javascript:" class="jsOnly DisplayIgnoredContent">{xen:phrase show_ignored_content}</a></li>
                        </xen:if>
                    </xen:hook>
                </xen:contentcheck>
            </ul>
        </xen:if>
       
        <xen:hook name="message_content" params="{xen:array 'message={$message}'}">
        <div class="messageContent">       
            <article>
                <blockquote class="messageText ugc baseHtml{xen:if $message.isIgnored, ' ignored'}">
                    <xen:include template="ad_message_body" />
                    {xen:raw $message.messageHtml}
                </blockquote>
            </article>
           
            {xen:raw $messageContentAfterTemplate}
        </div>
        </xen:hook>
       
       
        <xen:if is="{$visitor.content_show_signature} && {$message.signature}">
            <div class="baseHtml signature ugc{xen:if $message.isIgnored, ' ignored'}"><aside>{xen:raw $message.signatureHtml}</aside></div>
        </xen:if>
       
        {xen:raw $messageAfterTemplate}
       
        <div id="likes-{$messageId}"><xen:if is="{$message.likes}"><xen:include template="likes_summary" /></xen:if></div>
    </div>
   
    <xen:include template="ad_message_below" />
   
</li>
<xen:include template="adsense_post" />
 
An internal server error has nothing to do with the correctness of your template. Something about your server configuration doesn't like that request. For example, maybe there is an overzealous mod_security rule that is taking offense to the content of the template. You need to contact your web host or server person about this. The length may also be a clue for your host (since it works as two separate requests).
 
Top Bottom