$message.messageHtml origin in message template

corbitWire1

Member
Ok...this is my first post. I've been watching the forum for a few months and I have to say that xenForo rocks! Because xenForo rocks, I decided to start writing my own mods :) Here is my first question/problem:

I want to apply custom formatting to the first post of each thread. So I've overriden actionIndex() of XenForo_ControllerPublic_Thread through the use of my own class and a LoadClassController listener.

My class is the following:

PHP:
<?php

class SpecialPost_ControllerPublic_Thread extends XFCP_SpecialPost_ControllerPublic_Thread
{
    public function actionIndex()
    {
        $return = parent::actionIndex();

        $postid = $return->params['thread']['first_post_id'];
        if (isset ($return->params['posts'][$postid]))
        {
            $return->params['specialPost'][$postid] = $return->params['posts'][$postid];
            unset ($return->params['posts'][$postid]);
        }
        else
            $return->params['specialPost'] = array();

        return $return;
    }

}

Also I've modified a chuck of the 'thread_view' template as follows:

Code:
<ol class="messageList" id="messageList">

<xen:foreach loop="$specialPost" 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: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>

The problem is that the first post doesn't display it's message and the post's owner signature. It seems that $message.messageHtml and $message.signatureHtml found in the 'message' template don't exist or they are empty. The problem exists only in my own code referencing $specialPost.

I've checked the response of my controller and the base controller through print_r and neither $posts nor $specialPost contain a messageHtml or signatureHtml value. Where is the problem???
 
Both are created in the View.

See XenForo_ViewPublic_Thread_View, which calls XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages()
 
Kier, you are my hero! I searched almost everything regarding Thread stuff apart from XenForo_ViewPublic_Thread_View :rolleyes:

I am in love with xenForo as it brings a revolution to user and developer experience. Thanks for this amazing product and keep up the good work!
 
Actually my question is a test. I'am trying to write a simple article system which will apply custom formatting to the first post of each thread supporting pages through the use of [PAGE] bbcode. I thought about $post.position but I found it more appropriate to have a different array element in viewParams which will contain current article's page and the respective section of the actual first post. But...thanks for your suggestion! My mod will function in a similar way to GARS for vBulletin functions. I'll release my mod when it's basic functionality is built :)
 
Top Bottom