Files
kupshop/class/smarty_plugins/function.get_and_cache.php
2025-08-02 16:30:27 +02:00

15 lines
385 B
PHP

<?php
function smarty_function_get_and_cache($params, Smarty_Internal_Template $template)
{
$key = 'get_and_cache_'.md5(join('-', $params));
$data = getCache($key, $found);
if (!$found) {
$data = json_decode(file_get_contents($params['url']), true);
setCache($key, $data, $params['ttl'] ?? 7200);
}
$template->assign($params['assign'], $data);
}