|
Few Questions
|
|
08-11-2008, 11:32 PM
Post: #1
|
|||
|
|||
|
Few Questions
I'm working on a plugin at the moment and it's nearly done. I've used other plugins, the MyBB Wiki, and my small PHP knowledge to guide myself through the process. I'm kind of stuck, now.
This plugin is supposed to display extra information on users' postbits. The information is stored in a template that is called through a variable on the postbit or postbit_classic template. Upon turning it on, I get this error: Quote:Warning [2] call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'global_rpgstats' was given - Line: 141 - File: inc/class_plugins.php PHP 5.2.6 (Linux)
I'm certain it has something to do with how I did the hooks. I really have no clue what hooks do, or how to use them, but this is what I have after the error handling: PHP Code: $plugins->add_hook('postbit', 'postbit_author_rpgstats'); And another thing. The find and replace functions don't seem to be working for me. Upon activation, the following functions were set to run. PHP Code: // This inserts RPG stats var into postbit tempaltes.I'm losing hair quickly. If someone could point me in the right direction, it'd be nice. Thanks. |
|||
|
08-11-2008, 11:45 PM
Post: #2
|
|||
|
|||
|
RE: Few Questions
Hi,
For your error, it means that the function global_rpgstats doesn't exist. Either you added a hook you don't use, forgot to define a function or made a typo somewhere. For your find_replace_templatesets issue, your regex is incorrect. You might want to consider using preg_quote around it, eg: PHP Code: // This inserts RPG stats var into postbit tempaltes.(might be easier if you post all the code up) |
|||
|
08-12-2008, 12:16 AM
(This post was last modified: 08-12-2008 12:16 AM by Toasty.)
Post: #3
|
|||
|
|||
|
RE: Few Questions
Hey, Zinga. I'll drop the plugin, here goes:
PHP Code: <?phpBlam. Yeah. Thanks for your find and replace help. I'll implement that as soon as I get this hook thing sorted out. As for the hook, I only use it at the top. I don't know what else it's for, I pretty much got most of this done by looking at other plugins. >XD Thanks for your help! (I am the G Ninja )
|
|||
|
08-12-2008, 02:34 AM
Post: #4
|
|||
|
|||
|
RE: Few Questions
After fixing the find_replace_templatesets function from _activate and _deactivate, do this:
replace: PHP Code: $plugins->add_hook('postbit', 'postbit_author_rpgstats'); PHP Code: $plugins->add_hook('postbit', 'rpgstats_postbit'); (08-12-2008 12:16 AM)Toasty Wrote: I am the G NinjaO_O |
|||
|
08-12-2008, 03:35 AM
Post: #5
|
|||
|
|||
|
RE: Few Questions
Awesome. Everything is working perfectly except one thing.
PHP Code: <?phpThat's the new code with all the corrections (I even found a ton inconsistencies in the variables and stuff, it wouldn't have worked anyways; they're corrected now. >XD). Everything is functioning correctly, except $rpg_details isn't displaying postbit_author_rpg like it should. I think it has something to do with this line, here: PHP Code: eval("\$rpg_details = \"".$templates->get('postbit_author_rpg')."\";");
|
|||
|
08-12-2008, 07:15 AM
Post: #6
|
|||
|
|||
|
RE: Few Questions
By default, all variables defined within a function have local scope (which means they can only be "seen" from within the function).
Before the eval line, try adding: PHP Code: global $rpg_details; |
|||
|
08-12-2008, 07:53 PM
Post: #7
|
|||
|
|||
|
RE: Few Questions
That didn't seem to work. I checked the HTML source, and the template is still not even including onto the postbit. By the way, would I also have to put the individual variables used in the template in the global spectrum?
|
|||
|
08-13-2008, 08:50 AM
Post: #8
|
|||
|
|||
|
RE: Few Questions
Oops, I made a mistake. (ignore what I said above)
A few things: Use $post['rpg_details'] instead of $rpg_details, as the latter isn't available when evaling the postbit (you'll need to change your template edit as well). Secondly, change: PHP Code: function rpgstats_postbit($post) { PHP Code: function rpgstats_postbit(&$post) { |
|||
|
08-13-2008, 07:08 PM
(This post was last modified: 08-13-2008 08:12 PM by Toasty.)
Post: #9
|
|||
|
|||
|
RE: Few Questions
Ah, I initially had everything in the $post array, but I thought that's what was causing the original error.
Done and done. Now it's finally displaying, but the individual variables in postbit_author_rpg don't seem to be displaying. All the parameters show up, but what I've defined in things like $hpcur and $hpbar won't show what I've defined them as. I tried changing the variable names to include $post, but that doesn't work either. EDIT: I just found out that when deactivating, it doesn't find and replace "<br />{$post['rpg_details']}" into "". I tried it without preg_quote just for kicks and giggles and it still doesn't work. I have absolutely no clue why this isn't functioning normally. |
|||
|
08-17-2008, 07:40 AM
Post: #10
|
|||
|
|||
|
RE: Few Questions
Oh oops, forgot I needed to respond here
![]() Anyways, I can help with small issues, but for issues relating to the whole plugin, you're going to have to do it yourself. The reason the variables aren't showing is because the code isn't placed right, and it's more than just a simple modification to fix. You're really going to have to know what you're doing, unfortunately, or it's not going to work. For deactivation find_replace_templatesets, make sure you supply "0" as the 4th argument. |
|||
|
« Next Oldest | Next Newest »
|
Search
Member List
Calendar
Help





)
