Hello There, Guest! › Register

MySubscriptions 2.2 released.
Looking for a custom plugin for your site? Ask here for a quote.

How to make a "plugin" like MyShoutbox
#21

You need to make $server_bit global
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#22

(11-24-2012, 06:16 AM)Pirata Nervo Wrote: You need to make $server_bit global

You really lost me now.

So:
Code:
$plugins->add_hook("index_start","servers_func");
Somewhere on top, and I have this for the "servers_func()" function:
Code:
function servers_func() {
        global $mybb, $server_bit;
        
        if ($mybb->settings['enabled_servers'] == 1) {
            $server_bit = "<div id=\"lololol\"><center><h1>Server display works!</h1><br />Try to disable it!</center></div>";
        }
        return $server_bit;
    }

Is it really that hard to write me a simple example that just prints "hi" at the place where I put "{$servers}", I mean, a clean code, not a script with a lot of functions and such, I can't read through all that while I don't know what all the MyBB functions are because of their crappy documentation. And the reason I asked something is because I had to have something done about 4 days ago...
Reply
#23

The following code will replace "{var}" on the page by "Hi!".
PHP Code:
$plugins->add_hook('pre_output_page''foo');
function 
foo(&$page)
{
    
$page str_replace('{var}''Hi!'$page);


The following will do the same but ONLY in the header.
PHP Code:
$plugins->add_hook('global_end''foo');
function 
foo()
{
    global 
$header;

    
$header str_replace('{var}''Hi!'$header);


With the following code you will be able to place "{$var}" in any showthread (and probably other) template and it will be replaced by "Hi!".
PHP Code:
$plugins->add_hook('showthread_start''foo');
function 
foo()
{
    global 
$var;

    
$var 'Hi!';

Support PM's will be ignored. Exclamation
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
Reply
#24

@Cyberuben, it's not a matter of being hard or not. It's a matter of you not understanding how it works. You don't seem to know PHP at all, I already gave you a very easy example to understand and what you wanted me to do was to write you a sample that you could easily edit to your needs instead of writing your own. Sama34 ended up writing you one but make sure you remember that the easiest path is not always the best one.
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply
#25

(11-24-2012, 09:54 PM)Pirata Nervo Wrote: @Cyberuben, it's not a matter of being hard or not. It's a matter of you not understanding how it works. You don't seem to know PHP at all, I already gave you a very easy example to understand and what you wanted me to do was to write you a sample that you could easily edit to your needs instead of writing your own. Sama34 ended up writing you one but make sure you remember that the easiest path is not always the best one.

I'll tell you something funny. My dad builds websites for his living and has clients like some sections of the government because he knows what he's doing. Even he said that he couldn't find it out after your posts because of bad documentation.

(11-24-2012, 01:18 PM)Sama34 Wrote: The following code will replace "{var}" on the page by "Hi!".
PHP Code:
$plugins->add_hook('pre_output_page''foo');
function 
foo(&$page)
{
    
$page str_replace('{var}''Hi!'$page);


The following will do the same but ONLY in the header.
PHP Code:
$plugins->add_hook('global_end''foo');
function 
foo()
{
    global 
$header;

    
$header str_replace('{var}''Hi!'$header);


With the following code you will be able to place "{$var}" in any showthread (and probably other) template and it will be replaced by "Hi!".
PHP Code:
$plugins->add_hook('showthread_start''foo');
function 
foo()
{
    global 
$var;

    
$var 'Hi!';


Thank you very much.
Reply
#26

(11-24-2012, 10:01 PM)Cyberuben Wrote:
(11-24-2012, 09:54 PM)Pirata Nervo Wrote: @Cyberuben, it's not a matter of being hard or not. It's a matter of you not understanding how it works. You don't seem to know PHP at all, I already gave you a very easy example to understand and what you wanted me to do was to write you a sample that you could easily edit to your needs instead of writing your own. Sama34 ended up writing you one but make sure you remember that the easiest path is not always the best one.

I'll tell you something funny. My dad builds websites for his living and has clients like some sections of the government because he knows what he's doing. Even he said that he couldn't find it out after your posts because of bad documentation.

Just because he does that for a living, it doesn't mean he can understand how to write plugins for a forum software in a few minutes. Documentation is not the best part of MyBB, that's right, far from that. But I gave you a perfect example for someone, that with enough PHP knowledge and MyBB knowledge, can easily understand. Everyone started like that, and I see some very successful cases in the MyBB community.

If you expected me to write you an example (when there are many real examples out there) that you could easily copy paste and modify it, you were wrong. The description of the "Coding Help" section is very clear but you didn't read it, it seems.
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
Reply




Users browsing this thread: 1 Guest(s)