PDA

View Full Version : Datastore inside plugin code


Disasterpiece
09-21-2010, 02:29 PM
Hi again!

I'm basically through with my adminCP code of the plugin, while working on the code integration of the plugin itself, i got a little problem.

Due to caching mechanisms, I used datastore to store some information via cronjob.
If i want to access this information via adminCP file, it works with this code:
$specialtemplates = array(
'my_plugin'
);
And later on:
$this->cache = unserialize($vbulletin->my_plugin);

Everything fine. But:
Inside the plugin code which should actually display the plugin on the forumhome page, I can't access the cache var.
$vbulletin->my_plugin is NULL. Obviously I have to tell vB that this cache should be loaded too.

So I tried adding this line to my cache_template -hook:

if ($vbulletin->options['enable_my_plugin'])
{
$cache[] = 'forumhome_my_plugin';
$cache[] = 'my_plugin';
}
But, nothing happens. Template gets loaded, but cache from datastore doesn't get loaded.

Any advise how and where i have to add the cache identifyer to?

Paul M
09-21-2010, 02:35 PM
In global_state_check hook ;

$vbulletin->datastore->do_db_fetch("'my_plugin'");

Take special care to include both the double and single quotes.

Disasterpiece
09-21-2010, 02:50 PM
Nice and simple. Thx Mr. Paul :)