The website is for sale. Check here for more information.
This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.
How to make a "plugin" like MyShoutbox
#1
Hey,

I'd like to know how I can include something into a page like you do with MyShoutbox.

currently I just included an iframe into my MyBB index template, but I'd like to actually use a template function like {donationbar}.

I meant this: I want to include this page (http://casualbananas.com/forums/donationbar.php) into a template, using {donationbar} like you do with {myshoutbox_abcd} or something.
Reply
#2
You must code a plugin to eval the variable {$something} as PHP code (from a template for example) or replace {something} in the page before its output.

I recommend you to learn PHP first.
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#3
(11-09-2012, 09:54 AM)Pirata Nervo Wrote: You must code a plugin to eval the variable {$something} as PHP code (from a template for example) or replace {something} in the page before its output.

I recommend you to learn PHP first.

Yes I'm currently learning PHP. I know how it all works, MyBB is just something I don't get yet. I just figured out what Class Variables are and my own code for the donation-bar is working. I wanted to make a custom one, I know there are ones that exist already.

Anyways, on mybb.com they helped me with some links and a few pushes in the right direction, but is there a guide how to build a plugin from Scratch?
Reply
#4
Not exactly but perhaps I should write one. The best way to learn right now is by looking at existing plugins.
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#5
(11-09-2012, 09:12 PM)Pirata Nervo Wrote: Not exactly but perhaps I should write one. The best way to learn right now is by looking at existing plugins.

Could you give me a PM if you have written one? No rush.
Reply
#6
What do you mean? There are hundreds of plugins out there.
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#7
(11-10-2012, 01:11 AM)Pirata Nervo Wrote: What do you mean? There are hundreds of plugins out there.

A tutorial I mean Smile
Reply
#8
This is a little outdated my may still be enough:
http://mybbhacks.zingaburga.com/showthread.php?tid=74

Probably this should go in Coding Help Tongue?
Support PM's will be ignored. Exclamation
Reply
#9
Oh sorry misunderstood you. I said I "should write". I haven't written one yet Tongue

Moving to right section.
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#10
Look, I have the following right now:
Code:
<?php
    /*
    * Server display 1.0
    * © 2012 Ruben
    * http://casualbananas.com
    */

    if(!defined("IN_MYBB"))
    {
        die("You can not access this file directly!");
    }
    
    $plugins->add_hook("index_start","servers");
    
    function servers_info()
    {
        return array(
            "name"  => "Servers",
            "description"=> "Show all your clan servers on the index page!",
            "website"        => "http://casualbananas.com",
            "author"        => "Ruben",
            "authorsite"    => "http://casualbananas.com",
            "version"        => "1.0",
            "guid"             => "",
            "compatibility" => "*"
        );
    }
    
    function servers_activate() {
        global $db;
        
        $servers_group = array(
            'gid'    => 'NULL',
            'name'  => 'servers',
            'title'      => 'Servers',
            'description'    => 'Settings for the server display.',
            'disporder'    => "1",
            'isdefault'  => 'no',
        );
        
         $db->insert_query('settinggroups', $servers_group);
         $gid = $db->insert_id();
        
        $servers_setting = array(
            'sid'            => 'NULL',
            'name'        => 'enabled_servers',
            'title'            => 'Enabled',
            'description'    => 'Do you want the server display to show?',
            'optionscode'    => 'yesno',
            'value'        => '1',
            'disporder'        => 1,
            'gid'            => intval($gid),
        );
        
        $db->insert_query('settings', $servers_setting);
          rebuild_settings();
        
        find_replace_templatesets('index', '#{\$boardstats}#', "{servers}\n{\$boardstats}");
      }
    
    function servers_uninstall()
    {
        // Things to do when the plugin is uninstalled
        // ... should be reserved for altering the database!...
    }
    
    function servers_deactivate() {
          global $db;
        $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('enabled_servers')");
        $db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='servers'");
        rebuild_settings();
        
        find_replace_templatesets('index', '#{servers}#', '', 0);
    }
    
    function servers() {
        global $mybb;
        
        if ($mybb->settings['enabled_servers'] == 1) {
            echo "<center><h1>Server display works!</h1><br />Try to disable it!</center>";
        }
    }
?>
Could you explain me how to make it show something, for example, print $content, when I put {servers} in the index template?

Finally, it should display:
[Image: 1sGRx]
I have some decent PHP and MySQL knowledge but I have absolutely no idea how to work with the hooks. MyBB docs are so outdated and undetailed.

Also, could you answer me another question? I wrote another page (not a plugin), and I want to log something to the database. How to do this?
Code:
$write_log_array = array(
                                            "uid" => $mybb->user['uid'],
                                            "name" => $mybb->user['username'],
                                            "mode" => "from",
                                            "amount" => $bananas_amount,
                                            "time" => TIME_NOW
                                        );
                                        $db->insert_query("movebananas_log", $write_log_array);
TIME_NOW does nothing, and if I insert "NOW()" (the MySQL NOW()), it will just write 0000-00-00 00:00:00 to database. Any ideas?
Reply



  • View a Printable Version


Users browsing this thread: 1 Guest(s)

About MyBB-Plugins

Plug Yourself into the best MyBB AddOn.

Copyright © 2009-2021 MyBB-Plugins Forums.

Statistics

  • 51,000+ Posts
  • 19,000+ Members
  • 3,600+ Threads

Impressed? For sure
Check Full Stats here