Information about XenForo_Input and events

Evaelis

Active member
Hello there,
I recently bought XF and I have some questions about the addons system. Especially how XenForo_Input and events works.
Coming from VB3, I could easily change a thread title before it was posted just by doing
PHP:
$title = "New Title"
How can I edit the title, I already know about the XF overriding system, I just need to know how to modify the XenForo_Input or pass the new arguments to the original function.

For the events part, VB3 allowed me to hook at some predefined places. For example :
threadfpdata_postsave
allows you to hook and execute your code right after the thread is created. Therefore you can then award points for it or whatever you want to do.

Is there any way to execute a code before a thread is made and another one after the post is made?

If anyone got any ideas for me!
Thanks you.
 
The equivalent would be the XenForo_DataWriter_Discussion_Thread datawriter and the ... going from memory here ... _discussionPreSave() method.

This would give you access to everything you need before it is saved.

In the context of the datawriter you can check if the thread is being inserted or updated and if certain field values have changed.
 
Thanks for this answer, I found what I was looking for.
For those who might see this thread :

XenForo_DataWriter_DiscussionMessage_Post::_messagePreSave() allow you to change the post content / title / ...
Example :
PHP:
protected function _messagePreSave()
(
    parent::_messagePreSave();  
    $this->set("message", "New Message");
}
XenForo_DataWriter_DiscussionMessage_Post::__messagePostSave() allow you to check if it was an update, an insert, ... (See XenForo_DataWriter)

PHP:
protected function _messagePostSave()
{
    parent::_messagePostSave();
    if($this->isInsert()) {
        //New post
    }
}

XenForo_DataWriter_Discussion_Thread may allow you to do it on thread only, I'm on it.

Solved.
Thanks @Chris D for your precious help!
 
Back
Top Bottom