Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plugin error
#1
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!
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply
#2
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.
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#3
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!
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply
#4
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.
- Julian

My GetSimple Plugins: Simple Image Gallery | TweetMeme reTweet Button
Reply
#5
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?
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply




Users browsing this thread: 1 Guest(s)