View Full Version : Cache PHP widget separately for each language
postoronnim
02-17-2012, 09:17 AM
I use different content output for each language in the my CMS PHP Direct Execution Widgets.
if ($vbulletin->userinfo['languageid']) == 1) {
$output = "ENGLISH TEXT";
} else {
$output = "ANOTHER LANGUAGE TEXT";
}
But it does not work when I turn on caching for a widget. Shows last cached but not current language. How it can be cached separately for each language?
It doesn't seem to take in to account the language or style setting, as you found out. But I learned something about widgets (or at least php direct execution widgets), which is that there is a separate cached version per user. So if you switch the language setting you'll have to wait for the cache to expire, but if different users have different languages chosen, they should be OK.
If that doesn't work for you, I think you'd have to set the cache time to 0 and handle any caching yourself (see packages/vbcms/widget/execphp.php).
postoronnim
03-03-2012, 12:31 AM
Thank you very much, Kevin!
I went back to this problem and I solved it with your advise. I have changed 'userid' to 'languageid' in the getHash function and now my widgets caches separately for each language and my pages loads much faster!
Of course it is a very bad practice editing the vb-scripts, but I didn't see another way(
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.