PDA

View Full Version : A very simple question about datastore


Nj?rd Eriksson
07-18-2006, 03:44 AM
I have a string variable called $mydata

$mydata = "blahblah";

I succeeded to write it into datastore with

build_datastore('mycooldata', $mydata);

or

build_datastore('mycooldata', serialize($mydata));


But I can't seem to be able to read it out from datastore. I've seen this article

https://vborg.vbsupport.ru/showthread.php?t=110628

but whatever I try doesn't seem to work. Can anybody help? :cross-eyed:

---

EDIT:
Okay, I figured it out thanks to some posts on vb.org.

The solution is actually quite easy.

To write a string into datastore:
$mydata = "blahblah";
build_datastore('mycooldata', $mydata);

To be able to retrieve the data from the datastore, you have to add this to the config.php :

// Add any specialtemplates here for any products or mods that use the datastore, to save
// from re-doing file edits on an upgrade or re-install of vBulletin (until they give us a better
// way to do it, anyway). Thanks to KirbyDE for the how-to on doing this.
// mycooldata is a special template to read the latest mycool entries
// from the datastore without query
global $specialtemplates;
$specialtemplates = array_merge(
$specialtemplates, array(
'mycooldata',
));

To effectively display the datastore entry, insert this into a vBulletin template:

{$vbulletin->mycooldata}

Or you could retrieve the data in a plugin and then do something else with it:

$mydata = $vbulletin->mycooldata;