Node info and search seems to be only valueable for debug mode since in _thejit_spacetree_debug_node_info() node_id seems to have only one value for the whole tree and info is predefined? Is there any plan to use it per treenode like at myplant.org?

Comments

mrhanlon’s picture

You have to implement a search function and/or a node info and provide it in the configuration options for Spacetree. The functions implemented for the demo page I think just return "bogus" information as an example.

Here is a code snippet from myplant.org that shows the functions implemented there:

function clade_autocomplete($string = '') {
	$items = array();
	if ($string) {
		$sql = "SELECT title FROM {node} WHERE type = 'clade' AND LOWER(title) like LOWER('%s%%')";
		$result = db_query_range($sql, $string, 0, 10);
		while ($res = db_fetch_object($result)) {
			$items[$res->title] = check_plain($res->title);
		}
	}
	drupal_json($items);
}

function clade_jit_jit_help() {
	$helplinks = array();
	
	// about
	$helplinks[] = l(t('What is this?'), 'about/network-browser');
	
	// where is my clade
	$helplinks[] = l(t('Why is my clade missing from the tree?'), 'support/clade-suggestions');
	
	// faq
	$helplinks[] = l(t('My-Plant FAQ'), 'faq');
	
	return theme('item_list', $helplinks, '', 'ul', array('class'=>'iplant myplant'));
}

function clade_jit_jit_node_info($tid) {
	$clade = clade_get_clade($tid);
	if ($clade) {
		$result = array(
			'success' => TRUE,
			'title' => $clade->name,
			'body' => theme('clade_jit_node_info', $clade),
			);
	} else {
		$result = array('success' => FALSE);
	}
	print drupal_json($result);
	exit();
}

function clade_jit_spacetree($context_nid = 0, $jit_config = array()) {
	drupal_add_css(drupal_get_path('module', 'clade_jit') . '/css/clade_jit.css');
	
	$params = array(
		'id' => 'clade_jit_spacetree',
		'duration' => 250,
		'enable_hiding' => 1,
		'enable_full_screen' => 1,
		'enable_node_info' => 1,
		'node_info_path' => 'clade/jit/node_info/',  // hook_menu path for clade_jit_jit_node_info()
		'enable_help' => 1,
		'help_function_name' => 'clade_jit_jit_help',
		'enable_search' => 1,
		'search_path' => 'clade/autocomplete',  // hook_menu path for clade_autocomplete()
		'edge_color' => '#ffffff',
		'selected_edge_color' => '#db671e',
		);
	$settings = array_merge($params, $jit_config);
		
	if ($context_nid > 0) {
		$settings['node_to_select_id'] = $settings['id'] . '_' . $context_nid;
	}
	
	$clades = clade_jit_lookup_tree($settings['id']);
	
	return theme('jit_spacetree', $clades, $settings);
}

Note: this is D6 code. I haven't been working on the D7 version of JIT.

clemens.tolboom’s picture

For ie relation module which relates entities I want graphapi to provide a generic display responder ie

graphapi/ENTITY_TYPE/ENTITY_ID
graphapi/ENTITY_TYPE/ENTITY_ID/json

We could also user services.module maybe?

As for the debug forms I think we better move these to the admin settings pages so there are testable always by an admin.