Re: Q: Global content block limit? - Centralizing numerical values.
Posted: Wed Jul 23, 2008 8:21 am
Thank everybody, important thing is that we have started. 

Content management as it is meant to be
https://forum.cmsmadesimple.org/
Code: Select all
// Edit this line and point to your URL
$URL = "http://domain/val.csv";
global $gCms;
// if is not cached
if (!is_array($gCms->variables['csv']))
{
// Dont change anything further
$handle = fopen($URL,"r");
$array = array();
while (($data = fgetcsv($handle, 1000, ",")) !== false)
{
$x++;
if($x == 1)
{
$values = $data;
}
else
{
foreach ($data as $value)
{
if ($c == 0)
{
$array[$value] = array();
$element = $value;
}
else
{
$array[$element][$values[$c]] = $value;
}
$c++;
}
$c=0;
}
}
fclose ($handle);
// cache into a global variable
$gCms->variables['csv'] = $array;
return $array[$params['element']][$params['value']];
}
// if is cached
else
{
$array = $gCms->variables['csv'];
return $array[$params['element']][$params['value']];
}