/* * Written by: Susan Ottwell * Contact: [email protected] * Created: 10/11/2005 * For: MODx cms (modxcms.com) * Name: Glossary * Description: Manage termbase glossary * Parameters: &mod_path=Module Path (from site root);string;assets/modules/glossary * Parameter sharing: not enabled * Dependencies: none */ /* License Glossary - A MODx module which allows the management of the termbase glossary in the database Copyright (C) 2005 Susan Ottwell This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ $basePath = $modx->config['base_path']; // If we cant't find the module files... if(!file_exists($basePath.$mod_path)) { // Log an error $error_message = '<strong>Glossary module not found!</strong></p><p>Edit the Glossary module, click the Configuration tab and change the Module Path to point to the module.</p>'; $modx->Event->alert($error_message); $modx->logEvent(0, 3, $error_message, 'Glossary'); } else { $GLOBALS['glossary_path'] = $mod_path; // include the language file include($basePath.$mod_path.'/langs/en.php'); // if Browse or Search if(!empty($_POST) && isset($_POST['browse']) || isset($_POST['search'])) { include($basePath.$mod_path.'/mutate_termbase.dynamic.action.php'); } else { include($basePath.$mod_path.'/manage_termbase.dynamic.action.php'); } }
Note that this won’t work on most hosted environments as they tend to not grant the LOAD DATA permission. If you run your own box, however, it’s trivial.
I have been fiddling with the DataGrid widget myself, with an @SELECT binding but I did not manage to have it work as I would have wanted to. My goal was to get information stored in my TVs, and display it in a table with the caption and value of the TVs.
The thing that I found interessting in Widgets and @bindings was to be able to offer non-savvy people ways to do complex things. Might be so, but as Ryan said examples will probably help

You’re correct David. We indeed need some examples of the DataGrid widget but that’s going to take some planing and time.
Can you guys wait until TV2? The whole widgets thingy is being revised so it will be much easier to use.
DATE,EQ,FROM - ST,FROM CITY,TO CITY,TO ST 10/17/05,FDT,AL,MONTEVALLO,PIGGOTT,AR 10/20/05,FDT,AL,PINE APPLE ,PIGGOTT,AR 10/18/05,S/D ONLY,CA,SAN DIEGO,CORTEZ,CO 10/14/05,F,GA,MONROE,BATON ROUGE,LA 10/18/05,FD,IL,CHICAGO,CARROLLTON,TX 10/17/05,FD,IL,FRANKLIN PARK,MISHAWAKA,IN 10/10/05,FD,IL,FRANKLIN PARK,PORTSMOUTH,OH
@EVAL
$CSVf = "assets/files/board.csv";
if (file_exists($modx->config['base_path'].$CSVf)) {
$csvlines = file($modx->config['base_path'].$CSVf);
} else
return "Please wait while we update the load board file $modx->config['base_path'].$CSVf";
$lineNo= 1;
foreach ($csvlines as $line) {
if ($lineNo==1) $csvKeys= explode(',', $line);
else $csv = explode(',', $line);
$lineNo++;
}
$csvResult = array();
foreach($csvKeys as $indexnum => $key)
$csvResult[$key] = $csv[$indexnum];
return $csvResult;$csvlines = file($modx->config['base_path'].'assets/files/base.csv'); }
$csvout = '<table border=1 cellspacing=0 cellpadding=3>';
foreach ( $csvlines as $line )
{
$csv=explode(',',$line); $line='<tr><td>'.implode('</td><td>',$csv).'</td></tr>';
$csvout=$csvout.$line;
}
return $csvout.'</table>';@EVAL
$handle = fopen("/server/path/to/file/htdocs/assets/files/board.csv", "r");
$row = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($row) {
$results[] = $data;
}
$row++;
}
fclose($handle);
return $results;