warlord0
07-19-2013, 06:22 AM
I've been banging my head on the table trying to get my head around plugins and templates.
So far I have an installable product with plugins that hook the newthread_start and I've added a variable into the newthread template to place the fields. But I'm not sure I'm doing things the right way.
Template variable added:
{vb:raw addedfields}
Plugin newthread_start:
$flds= '<fieldset><label> Random checkbox <input type="checkbox" name="chkrandom" /></label></fieldset>';
vB_Template::preRegister('newthread', array('addedfields' => $flds));
Which works and I get my checkbox. The problem I have is if I try to make use of variables/phrases in the plugin variable.
eg.
$flds= '<fieldset><label> {vb:raw title} <input type="checkbox" name="chkrandom" /></label></fieldset>';
This doesn't do any variable substitution and I end up with the {} variable as visible html.
I used this article as a reference (https://vborg.vbsupport.ru/showthread.php?t=237982) - and I am struggling to understand it to be fair, but I do get it sort of working.
Eventually I want to be able to store the custom field values in with the thread, but haven't found any guidance to point me to how to do that. Any one got any good guideas for doing this?
Many thanks.
--------------- Added 1374234105 at 1374234105 ---------------
Ok, I'm really struggling with this. I'm getting no where fast and the documentation is like trying to do a jigsaw in the dark with no picture to to do it with.
How do people get started with developing a product and plugins? All the articles seem to assume you know enough about vb development - which I plainly don't. I have a fair understanding of php, but don't have the knowledge of applying it to the way vb works.
I thought I'd got a simple plan for what I wanted to achieve. There is an existing plugin that does close to what I'm after I just wanted to go a little different.
Basically I'd like to use a "Sticky Post" so that it remains at the top of every page.
To do that I'd like the user or admin to choose if it is sticky or not. Simple checkbox added to newthread and value stored in the thread table as "stickyfirstpost"
Then as postbit is processed check is $thread['stickyfirstpost'] is true and GPC['pagenumber'] > 1 - if so repeat the $thread['firstpost']
I can figure the logic of the existing plugin and can make it check the $thread['stickyfirstpost'] value and it works. But what I can't do is modify the newthread template and have it save the data into the table. The field exists, but nothing gets written into it ever.
https://vborg.vbsupport.ru/showthread.php?t=239282
I guess I'm missing the understanding of handling the vbulletin objects. So where do I learn this?
So far I have an installable product with plugins that hook the newthread_start and I've added a variable into the newthread template to place the fields. But I'm not sure I'm doing things the right way.
Template variable added:
{vb:raw addedfields}
Plugin newthread_start:
$flds= '<fieldset><label> Random checkbox <input type="checkbox" name="chkrandom" /></label></fieldset>';
vB_Template::preRegister('newthread', array('addedfields' => $flds));
Which works and I get my checkbox. The problem I have is if I try to make use of variables/phrases in the plugin variable.
eg.
$flds= '<fieldset><label> {vb:raw title} <input type="checkbox" name="chkrandom" /></label></fieldset>';
This doesn't do any variable substitution and I end up with the {} variable as visible html.
I used this article as a reference (https://vborg.vbsupport.ru/showthread.php?t=237982) - and I am struggling to understand it to be fair, but I do get it sort of working.
Eventually I want to be able to store the custom field values in with the thread, but haven't found any guidance to point me to how to do that. Any one got any good guideas for doing this?
Many thanks.
--------------- Added 1374234105 at 1374234105 ---------------
Ok, I'm really struggling with this. I'm getting no where fast and the documentation is like trying to do a jigsaw in the dark with no picture to to do it with.
How do people get started with developing a product and plugins? All the articles seem to assume you know enough about vb development - which I plainly don't. I have a fair understanding of php, but don't have the knowledge of applying it to the way vb works.
I thought I'd got a simple plan for what I wanted to achieve. There is an existing plugin that does close to what I'm after I just wanted to go a little different.
Basically I'd like to use a "Sticky Post" so that it remains at the top of every page.
To do that I'd like the user or admin to choose if it is sticky or not. Simple checkbox added to newthread and value stored in the thread table as "stickyfirstpost"
Then as postbit is processed check is $thread['stickyfirstpost'] is true and GPC['pagenumber'] > 1 - if so repeat the $thread['firstpost']
I can figure the logic of the existing plugin and can make it check the $thread['stickyfirstpost'] value and it works. But what I can't do is modify the newthread template and have it save the data into the table. The field exists, but nothing gets written into it ever.
https://vborg.vbsupport.ru/showthread.php?t=239282
I guess I'm missing the understanding of handling the vbulletin objects. So where do I learn this?