I am using Drupal 7 and CTools. I want to create a jump menu using Ctools. I have checked the example code provided in the Ctools module. And it is working fine for one link only.
How do I add more links in Jump menu:
In the code shown below, look at here: $url = url('mypostings/groupsort'); I want to add more links in the jump menu,like url('mypostings/test1'), url('mypostings/test2') etc..
/**
* Implementation of hook_menu();
* @return
*/
function post_display_menu() {
$items['mypostings'] = array(
'title' => 'My Posts in Group',
'page callback' => 'get_my_postings',
'access callback' => TRUE,
'expanded' => TRUE,
);
$items['mypostings/groupsort'] = array(
'title' => 'My Postings Filter',
'page callback' => 'get_my_posting_filter',
'access arguments' => array('access simple page'),
);
return $items;
}
function get_my_postings() {
global $user;
// Include the CTools tools that we need.
ctools_include('ajax');
ctools_include('modal');
// Add CTools' javascript to the page.
ctools_modal_add_js();
$header = array(
array('data' => t('Title'), 'field' => 'n.title'),
array('data' => t('Created'), 'field' => 'n.created'),
array('data' => t('Author'), 'field' => 'u.name'),
);
$query = db_select('node', 'n');
$query->leftjoin('users', 'u', 'u.uid = n.uid');
$query->fields('n',array('title', 'created'))
->fields('u',array('name'))
->groupBy('n.nid');
$result = $query->execute();
$rows = array();
foreach ($result as $row) {
$rows[] = array('data' => (array) $row);
}
$build['tablesort_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
drupal_add_js($sample_style, 'setting');
ctools_add_js('ctools-ajax-sample', 'ctools_ajax_sample');
ctools_add_css('ctools-ajax-sample', 'ctools_ajax_sample');
$output .= $build;
// Create a jump menu
ctools_include('jump-menu');
$form = drupal_get_form('post_filter_jump_menu_form');
$output .= '<h3>'. t('Jump Menu') .'</h3>';
$output .= drupal_render($form);
return array('markup' => array('#markup' => $output));
return $build;
}
/**
* Helper function to provide a sample jump menu form
*/
function ctools_ajax_sample_jump_menu_form() {
$url = url('mypostings/groupsort'); // I want to add 3 links in jump menu How can i add it
$form_state = array();
$form = ctools_jump_menu(array(), $form_state, array($url => t('Sort')), array());
return $form;
}