This was a great article and it explained the concept very well. I do have a minor quibble in your example. Rather than name= dog, value=dog, it might help people understand better if the var name and var value were different, e.g. name=dog, value=terrier.
Something I'd add to the discussion is that cron and serialize go hand in hand. The best place to use serialize is when accessing data frequently, therefore using vb's cached datastore w/o adding a query...but the updating of data is relatively infrequent. A classic way to update that data periodically is cron. https://vborg.vbsupport.ru/showthrea...highlight=cron |
I really hope they add a hook that will allow us to add to $specialtemplates before it's actually used. It's kind of a bummer to have to hack up a file over something so simple.
Not to suggest that adding the hook is simple. I think there's some initialization for the hook system in the datastore, or something along those lines. It's just a pain and it would be cool if they stumble across some fix in the future. |
Quote:
|
It's because the query that uses $specialtemplates and populates the datastore variables comes before global_start. I don't really understand why, but I think it has something to do with the hook system not being able to work until the datastore info is available.
|
Have you tried the init_startup hook? There is another Datastore fetch executed after it I think. This isn't tested but you could maybe try:
Hook Location: init_startup PHP Code:
|
Awesome, thanks man. I haven't tested it either, but it looks like that should work.
--------------- Added [DATE]1194736320[/DATE] at [TIME]1194736320[/TIME] --------------- Ok, it did work. It added the extra query, but it works. You have to be careful and make sure it's like this though: Code:
$datastore_fetch[] = "'dropmenu'"; |
Ooops yup you need to put it in quotes because otherwise MySQL will read it as a column name instead of a value.
I'll correct it in my original post. |
The Function build_datastore also has a 3rd parameter which should be mentioned, as it seems all serialized data in the datastore table requires a value of 1...
PHP Code:
$vbulletin->dropmenu = unserialize($vbulletin->dropmenu); There'fore we can just access the info from the datastore like this: PHP Code:
|
<font color="darkgreen">What if I have my own class object and I want to build cache acessible from it only and not use the $vbulletin object?
Like ... $myclass->mycache['something'] instead of $vbulletin->mycache['something'] How would I change it so its like that?</font> |
With a couple tweaks (probably because this is 2 years old...), i've successfully got my first datastore plugin working :)
Thanks for the write up Ken. Never experienced with the datastore much. |
All times are GMT. The time now is 10:47 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|