MyBB Community Forums

Full Version: Plugin Authoring For Beginners [Part 1] / How to create plugins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
When will be part 2?

I would like to see an example: When I click on a button in the topic. The selected row and column (in databse), the value will increase by 1
(2013-02-25, 09:13 PM)qwertyx Wrote: [ -> ]When will be part 2?

I would like to see an example: When I click on a button in the topic. The selected row and column (in databse), the value will increase by 1

A basic example would be like this:

<form action="increment.php" method="post">
<input type="submit" value="Increment by One" />
</form>

Then, in increment.php, you would do something like this:

//Grab the value of $field
$field = $db->write_query("SELECT `field` FROM `table` WHERE `clause`='1'");

$field = $field + 1;

$db->write_query("UPDATE `table` SET `field`='" . $field . "'");
Ain't Nobody got time fo dat!
k let say i want to show these things after header.. so when i use "index_start" hook. how to do that. can anyone help me to do that... just explain me.
useless, perhaps how to make an actual, worthwhile plugin help?

Like, how do you query what forum the user's currently vuiewing.
It is rather redundant to keep showing the structure but none of the methods in a manual.... thats why I hate Java's documrentation.
(2014-06-25, 02:45 PM)Chathula Wrote: [ -> ]k let say i want to show these things after header.. so when i use "index_start" hook. how to do that. can anyone help me to do that... just explain me.

In your plugins file you will need the following code:
$plugins->add_hook("index_start", "my_function");
function my_function()
{
// do something here
// If you are wanting to use a variable in a template, you will need to declare it as a global in this function.
}
Why not post a full list of the mybb globals and their methods? i dont got the time nor the data tpo constantly look stuff online.
Thanks for making this tutorial i myself have a basic understanding of php and this helped me out even more! Thanks for the topic/post once again! Smile
Copied the code and steps exactly. and I get this error message.
"My First Plugin (1.0)
This is my first plugin! Smile
Created by Vernier This plugin is incompatible with MyBB 1.8.3"

Anyone know how to update this plugin so it is compatible? Or is there something i am doing wrong here?
(2015-03-24, 07:23 PM)MikesPad Wrote: [ -> ]Copied the code and steps exactly. and I get this error message.
"My First Plugin (1.0)
This is my first plugin! Smile
Created by Vernier This plugin is incompatible with MyBB 1.8.3"

Anyone know how to update this plugin so it is compatible? Or is there something i am doing wrong here?

"compatibility" => "18*"
Pages: 1 2 3 4 5 6