GetSimple Support Forum

Full Version: Plugin error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys, I have began my first plugin, an the first thing I noticed as I was learning I 'stole' some code from another plugin. (Just for learning purposes.) that created a menu object within the Plugins menu and had just some random content on that page. Here is what I did and what happened. I am not really sure if this is a problem or if it can even be helped...

This is the code I used to display the content on the admin page.
Code:
function sc_options() {
    print "<h2>This is my first plugin...</h2>
    <p>This is an explanation of my first plugin!</p>";
}

I 'stole' the code from internet54 who's plugin I also have installed. after installing my plugin, I visit the plugins page and it will not load at all.

I believe it would be because there was 2 functions that are the same thing attempting to be run at one time. I changed the code from the above to
Code:
function sf_options() {
    print "<h2>This is my first plugin...</h2>
    <p>This is an explanation of my first plugin!</p>";
}
and it loads and works fine...

Let me know if this is a real error or not, thanks!
Yes, I encountered that problem before.
If a function name is identical to another functions name, php throws blank pages.
That's why I used sc_ for my function names in the simple contact plugin.
Glad to see I am not the only one who encountered this error.

Also hope you didn't mind me using your plugin as a base for learning to write plugins myself!

Also, your plugin is great!
I encounter the same problem. I even posted a few days ago a suggestion that the hooks can be incorporated using methods of a class. That way wrapping all the plugin functionality in an object prevents function name collision. Ofcourse there can be a class name collision, but putting a prefix such as your comp name can help you avoid this problem.
Is there a way to abstract the plugin loading so it automatically becomes part of a class, and the class randomly generates a class and instance name which is different to any other?

That way the coding doesn't have to be changed, but the collision would be removed?