View Full Version : Datastore - How to display data?
Aurous
05-01-2006, 11:55 PM
Hello
I am facing a problem and cant seem to grab the general idea of how datastore caching works in vBulletin 3.5.x.
I created a new row in datastore:
title data
radiocache info that updates every few minutes via cron file.
Now this data is to be displayed in Index.php and basically here's where the problem starts. In 3.0.x version I just edited init.php and added radiocache in "$specialtemplates" and used $datastore[radiocache] in template to display the data. But now, I am a bit confused with how things work in vb 3.5.0
I searched around but didnt find enough information to solve my problem. I am not very good with php/mysql. Here's what I tried so far:
I edited index.php and added radiocache to the $specialtemplates array. How do I go about it from there? Any help will be much appreciated. I am sure this will also help other coders who are interested in datastore.
Just so you know, I am using vB 3.5.4.
Thanks.
Aurous
Adrian Schneider
05-02-2006, 01:22 AM
In 3.5, datastore goes to: $vbulletin->fieldName... so in your case $vbulletin->radiocache.
Aurous
05-02-2006, 02:18 AM
I already tried that, but it doesnt display anything. No results on the page whatsoever, while the data is obviously there in the table. Also added 'radiocache' in index.php :
$specialtemplates = array(
'userstats',
'birthdaycache',
'maxloggedin',
'iconcache',
'eventcache',
'mailqueue',
'radiocache'
);
Am I missing anything else here?
Adrian Schneider
05-02-2006, 03:14 AM
$vbulletin->anything won't work in templates unless you enclose it in braces ( {}s ). What do you have stored there?
Aurous
05-02-2006, 09:00 AM
Well right now I just have "test" (without quotes) and nothing shows. I tried "{test}" and that didnt help either. Can you please test this out and see if its working for u? Anything to work in functions_databuild.php ?
Adrian Schneider
05-02-2006, 01:39 PM
{$vbulletin->test} in the template
Aurous
05-03-2006, 12:27 AM
Ahh! Thank you so much. Works fine now.
Aurous
05-09-2006, 03:00 PM
Quick question:
Is there any work around for $specialtemplates yet? Basically any work around to NOT edit .php file that is. BTW, this method -> https://vborg.vbsupport.ru/showthread.php?p=770801#post770801
doesnt work anymore.
Although, Kirby's solution work fine as mentioned in Boofo's post -> https://vborg.vbsupport.ru/showthread.php?p=771970#post771970
Any workaround yet?
Boofo
05-09-2006, 03:06 PM
Quick question:
Is there any work around for $specialtemplates yet? Basically any work around to NOT edit .php file that is. BTW, this method -> https://vborg.vbsupport.ru/showthread.php?p=770801#post770801
doesnt work anymore.
Although, Kirby's solution work fine as mentioned in Boofo's post -> https://vborg.vbsupport.ru/showthread.php?p=771970#post771970
Any workaround yet?
Nope, that's the only way to do it for now. But since the config.php doesn't get overwritten on an upgrade, no need to re-edit the file. ;)
And they both do still work, by the way. I am using it both ways in my config.php. ;)
Aurous
05-09-2006, 03:15 PM
Hmm, that is sad! Any word from vBulletin regarding this? I mean on one hand they want to promote plugins and on other they have a system where you cant really live without a file edit. Although config.php isnt a big issue here, but why edit anything to begin with?
I tried editing config.php as follows:
if (THIS_SCRIPT == 'index')
{
$specialtemplates[] = 'item';
}
but it didnt show anything in the index page. Then I just edited the $specialtemplate array in index.php manually, added 'item' and it worked fine.
Boofo
05-09-2006, 03:18 PM
Here's what I use and it works perfectly. ;)
if(THIS_SCRIPT == 'index')
{
global $specialtemplates;
$specialtemplates = array_merge($specialtemplates, array('boofocounter','averagevelocity','topvelocit y','wol_spiders'));
}
You need the global part. Yours is for a single template also.
Aurous
05-09-2006, 03:39 PM
Oh ya, I forgot about declaring global variable. This works too for single template.
if (THIS_SCRIPT == 'index')
{
global $specialtemplates;
$specialtemplates[] = 'item';
}
hmm we can use this for multiple templates too I believe:
$specialtemplates[] = 'item1';
$specialtemplates[] = 'item2';
etc.
Boofo
05-09-2006, 04:08 PM
Oh ya, I forgot about declaring global variable. This works too for single template.
if (THIS_SCRIPT == 'index')
{
global $specialtemplates;
$specialtemplates[] = 'item';
}
hmm we can use this for multiple templates too I believe:
$specialtemplates[] = 'item1';
$specialtemplates[] = 'item2';
etc.
No, use the array_merge for multiple templates. ;)
Aurous
05-09-2006, 04:38 PM
Ok. Thanks for all the info :) I am starting to like datastore!
Boofo
05-09-2006, 04:41 PM
Ok. Thanks for all the info :) I am starting to like datastore!
Remember, the datastore is your friend. ;)
I try to use it whenever I can. We just did a forumhome counter for my site that uses the datastore and saves on an unessessary query. It uses 1 query to update the datastore and no query to pull the info from the datstore. It works great. ;)
Aurous
05-09-2006, 04:51 PM
Yup, I just helped a user on vB by changing his hack by storing data in datastore instead of a text file. Works great.
https://vborg.vbsupport.ru/showthread.php?threadid=115116
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.