Marcel
Active member
After having a crash course into the land of PHP beyond my basic capabilities, coupled with an in-flight meal of OOP, served with side dishes of classes, methods, controllers etc....I have managed to put together my very first plugin.
The idea for the plugin is to have a 'One click' prefix at the top of a thread, which adds a pre-chosen prefix to the thread. (Which I've set up in the Admin options).
I know this task is simple enough with "Thread tools > Edit > Choose Prefix > Save".
Anyway, I've got the plugin working with the following action / route
thread/1234/sold
Which does exactly what I want it to, changes the prefix to the one I've chosen in the options, no frills no fuss. Now I've got this working I want to tidy up the code, adding proper authentication checks, error messages etc.
Firstly, I want to check if the thread has our "Sold" prefix already, and if so, return out with an error.
I get the thread info via this line in the method
$thread = $this->getModelFromCache('XenForo_Model_Thread')->getThreadById($threadId);
Does $thread now contain the prefix ID? If it does, I can't find it...what in-between scouring and searching the XenForo files and google.
The idea for the plugin is to have a 'One click' prefix at the top of a thread, which adds a pre-chosen prefix to the thread. (Which I've set up in the Admin options).
I know this task is simple enough with "Thread tools > Edit > Choose Prefix > Save".
Anyway, I've got the plugin working with the following action / route
thread/1234/sold
Which does exactly what I want it to, changes the prefix to the one I've chosen in the options, no frills no fuss. Now I've got this working I want to tidy up the code, adding proper authentication checks, error messages etc.
Firstly, I want to check if the thread has our "Sold" prefix already, and if so, return out with an error.
I get the thread info via this line in the method
$thread = $this->getModelFromCache('XenForo_Model_Thread')->getThreadById($threadId);
Does $thread now contain the prefix ID? If it does, I can't find it...what in-between scouring and searching the XenForo files and google.