|
Common Errors when making a plugin
|
|
01-16-2006, 04:12 PM
(This post was last modified: 01-16-2006 04:46 PM by zaher1988.)
Post: #1
|
|||
|
|||
|
Common Errors when making a plugin
Heloo there,
I'd like to state here some common errors that you might encounter when making your own plugins, a little bit of my little experience in plugins for those who are new. 1- Correct & Common naming When making a plugin you should ensure to have a common name for the plugin and for the activation , deactivation, info etc...functions. what i mean in. if you make for example PHP Code: function icons_activate() your plugin file should be called icons. or you will not find your plugin in the plugin manager, or the plugin will not work. 2- Escaping all joker characters like $, [, ], ?, ( and ). When making a plugin and u miss escaping the jokers, you'll plugin will not do the job when activated. this is only apllied for the find string in the function find_replace_templatesets. What i mean by escaping is in case u have Quote:$mybbuser[avatar] you have to escape it using "\" Quote:\$mybbuser\[avatar\] 3-When having multilines It's better that in the search part of the replace templateset, that you dont use multipule lines. however if u have multipule lines make sure to include the letter "s" after the # for example PHP Code: "#<td valign="top" align="right">4-Watch up not to use "0" in activate You dont incluse "0" at the end of the activation for a certain change of templates. As 0 means you don't want to create a new template. however if you change something, you must create a new template otherwise reverting to original won't be possible. so only use it for deactivating umm in case others would like to add things here you're free ![]() bbye |
|||
|
01-16-2006, 04:36 PM
Post: #2
|
|||
|
|||
|
RE: Common Errors when making a plugin
I didnt know about #3. cool
![]() "Coming together is a beginning; keeping together is a process; working together is success." -Henry Ford To travel is better than to arrive. |
|||
|
01-16-2006, 04:38 PM
Post: #3
|
|||
|
|||
|
RE: Common Errors when making a plugin
Just to correct and add to the above
2- Escaping all joker characters like $, [, ], ?, ( and ). You should NOT escape all the characters in your plugin, just the ones used for the find string in the function find_replace_templatesets I think the above poster is referring to the function find_replace_templatesets. This function will basically search a specified template with the search string and replace it with something else. The function uses the function preg_replace to look for code. This means you have to 'escape' certain characters. Most noticeably $ and all of the brackets ([{}]). There are a few others but these are the main ones you need to know about. You should use the function preg_quote to do all of this work for you. You should also store your search strings in string values instead of copying/pasting the code into the relevant places. If you want to search for something and add something after the search string, some people might use Code: require_once("inc/adminfunctions_templates.php");Code: $find_string = "reputation";4-Watch up not to use "0" in activate When you use the function find_replace_templatesets the last parameter is optional. If it isn't used, or set to 1, it will create a new template from the 'master' template. This means an option will appear in the Admin CP for users to revert back to the original (default) template. If set to 0 then it will try to edit all templates with that title. So when you install/edit a template for the first time (read: activating a plugin) using the function find_replace_templatesets, you should omit this parameter so that it will create a copy of the master template you are trying to edit. And when you are deactivating your plugin, you should set this parameter to 0. Like in the code above/below Code: $find_string = "reputation";Notice the extra parameter at the end of the function in plugin_deactive. That will make the find/replace work on all templates with that name. I will add some more tips when my eyes are working. Updated Site! My mods 1.1: MyBB Zip Installer, Easy Install v2.0, Cash/Points plugin, PayPal/Subscriber, Reply by email, Advanced Plugins |
|||
|
01-16-2006, 04:43 PM
Post: #4
|
|||
|
|||
|
RE: Common Errors when making a plugin
yes sorry regarding the 2nd one
i forgot to mention that yes it's only for the find string in the function find_replace_templatesets i'll edit my post ![]() ciao |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)
Search
Member List
Calendar
Help





![[Image: ryangordon.png]](http://ryangordon.net/ryangordon.png)
