(06-29-2010 04:53 PM)Walkman 5.0 Wrote: this is my firs advanced plugin
Wow, really? Then congratulations. My first advanced programs/scripts were horrible. You did fairly well then
(06-29-2010 04:53 PM)Walkman 5.0 Wrote: ammm any example of the unoptimisate path?
Do you mean my first point?
Try putting your call to
build_thank after you've done the various checks there.
You have a nice
$thx_cache variable actually, which you've used for caching username styles - perhaps, also try caching the results from the query as well.
If you look at showthread.php, MyBB uses the $pids variable to pull posts out, so you can change your query, replace
WHERE th.pid='$pid' with
WHERE th.$pids.
Do note that $pids is only set on linear display - threaded display doesn't use the variable, so you need to also double check that $pids is set before trying to build a cache.
Anyway, you can build the cache in the
thx function, and then, in the
build_thank function, check if the result has been cached. If it has, use that instead of a query, if not, you'll have to fall back to a query.
That would be my suggestion on how to implement it.
Hope that helps. If it's too confusing, feel free to ask, specifying which part you're having trouble with.
And thanks for your work in the plugin!