Razasharp
Well-known member
I'd thought I'd start off with something simple as my first plugin... but it is proving more difficult than I envisaged
I'd like to show the prefix with the last post details on the forum home and forum listing pages.
There is a xf_forum table that holds the caches for forums, and adding a couple of columns into this should be simple enough. Then we just need to piggy-back off the existing methods to include the details when updating the table, and consequently reading from it.
So it seems relatively simple, but it is eluding me (and even other mod authors). Can you help? I am happy for whoever helps with this to release it as part of their portfolio, or release it here myself and transfer all rights to Xenforo Ltd. I'd really appreciate your help on this as I think it is the only thing left that I would really really like to include with the launch of my first XF forum
There is a plugin that is meant to do this already (it doesn't work as expected tho - and the author has said he's finding it difficult to achieve too) so we have a good starting point already. Here's how I imagine it would work so far:
Step one - create columns in xf_forum table.
This is the cache table that XF uses for forums. I propose we add two columns to this, one for the prefix class and one for the prefix text. Perhaps, prefix_plugin_last_post_prefix_class and prefix_plugin_last_post_prefix_text
Step two - include these columns when XF updates the cache normally. After a post is made/moved, XF updates the cache for that forum. In the Post Controller, and actionSave action, it says it is to update an existing post - should there be a create action anywhere? Ok this seems to be handled by the _discussionPostSave() and updateLastPost() methods in DataWriter.php. So we just need to update this to include our columns (?)
Step three - making the info available to the necessary templates/controller actions. This seems to be the part that has stumped us. I guess we need to utilise getNodeDataForListDisplay which is in the Node Model. But I don't really understand what's going on here.
Am I on the right track? Does anyone know where to go from here? I am a PHP noob, but do have a fairly good understanding of OOP and MVC ...your help (and patience!) would be very much appreciated.
I'd like to show the prefix with the last post details on the forum home and forum listing pages.
There is a xf_forum table that holds the caches for forums, and adding a couple of columns into this should be simple enough. Then we just need to piggy-back off the existing methods to include the details when updating the table, and consequently reading from it.
So it seems relatively simple, but it is eluding me (and even other mod authors). Can you help? I am happy for whoever helps with this to release it as part of their portfolio, or release it here myself and transfer all rights to Xenforo Ltd. I'd really appreciate your help on this as I think it is the only thing left that I would really really like to include with the launch of my first XF forum
---------------------------------------------------
Thoughts so far
There is a plugin that is meant to do this already (it doesn't work as expected tho - and the author has said he's finding it difficult to achieve too) so we have a good starting point already. Here's how I imagine it would work so far:
Step one - create columns in xf_forum table.
This is the cache table that XF uses for forums. I propose we add two columns to this, one for the prefix class and one for the prefix text. Perhaps, prefix_plugin_last_post_prefix_class and prefix_plugin_last_post_prefix_text
Step two - include these columns when XF updates the cache normally. After a post is made/moved, XF updates the cache for that forum. In the Post Controller, and actionSave action, it says it is to update an existing post - should there be a create action anywhere? Ok this seems to be handled by the _discussionPostSave() and updateLastPost() methods in DataWriter.php. So we just need to update this to include our columns (?)
PHP:
{
$lastPost = $this->_getLastMessageInDiscussion();
if ($lastPost)
{
$messageStructure = $this->_messageDefinition->getMessageStructure();
$this->set('last_post_id', $lastPost[$messageStructure['key']]);
$this->set('last_post_date', $lastPost['post_date']);
$this->set('last_post_user_id', $lastPost['user_id']);
$this->set('last_post_username', $lastPost['username']);
>
>
}
else
{
$this->set('last_post_id', $this->get('first_post_id'));
$this->set('last_post_date', $this->get('post_date'));
$this->set('last_post_user_id', $this->get('user_id'));
$this->set('last_post_username', $this->get('username'));
>
>
}
}
Step three - making the info available to the necessary templates/controller actions. This seems to be the part that has stumped us. I guess we need to utilise getNodeDataForListDisplay which is in the Node Model. But I don't really understand what's going on here.
Am I on the right track? Does anyone know where to go from here? I am a PHP noob, but do have a fairly good understanding of OOP and MVC ...your help (and patience!) would be very much appreciated.
Last edited: