hello
I am trying to create a module which displays a tree menu similar to one that we see in windows explorer. I am using tiagara tree menu. Tiagara tree menu is written in javascript and needs two array to initialize it. I am not sure how can I generate javascript array within modules. I get the data from mysql and now want to create a javascript array. Below is the module code in which I am trying to include javascript.
function viewer_content() {
$path = drupal_get_path('module', 'viewer');
theme_add_style($path . '/custom.css');
// Calculate previous and next record
$index = $_SESSION['QBIndex'];
$prev = $index - 10;
$next = $index + 10;
if($prev < 0) $prev = 0;
// in future this should not be here
db_set_active('spy');
$sql = 'SELECT article_id, title, pub_date FROM article order by title';
$result = @mysql_query($sql);
$output .= '
';
$output .= '
';
if(empty($result)) return '';
while ($row = @mysql_fetch_array($result)) {
$output .= '
' . l($row['title'], 'node/4/'. $row['article_id']) . '
';
// instead of putting results in a div
// i need to create a javascript array
// and call a java script function which builds a tree menu
// new tree(treeItems, treeIcons)
}
$output .= '
';
db_set_active('default');
//$output .= '
Current Value is ' . $index . '
';