Posted by vishakhaPohane on February 11, 2013 at 5:56am
Hi,
I am working with one project which is based on online registration for schools and colleges.
So i have created registration form for students. In that form they can view school/college list with one link sendQuery.
This sendQuery link should open one popup window having three fields 1.listbox of all schools/colleges, 2.Query title, 3.Body, 4.Send button - in which students can ask the queries.
After sending the query, admin can should view the queries which is sent by students.
Can anybody give me some idea about how to create this module.
Please help me..
I am waiting for the reply..
Thank you...
Comments
HI
Hi
Please have look below listed code to create custom module for above listed feature.
Module name = 'Query_custom'
1) create folder with name 'query_custom'
2) create folder with name 'query_custom.info' under the folder 'query_custom'
; $Id: query_custom.info,v 1.01 2013/02/12 19:59:45 tusharb Exp $
name = "Query Module"
description = Module provide the send query functionality for registration.
core = 7.x
files[] = query_custom.module
package = "Custom Module"
dependencies[] = ctools
; check http://example.com/student_registration replace example.com with your domain name.
3) Create file with name 'query_custom.module' under the folder 'query_custom'
<?php
function query_custom_menu() {
$items = array();
$items['query_custom/%ctools_js/send'] = array(
'title' => t("Send query"),
'page callback' => '_send_query_modal_box',
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM,
);
$items['student_registration'] = array(
'title' => 'Student Registration',
'page callback' => 'drupal_get_form',
'page arguments'=> array('_student_registration_form'),
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function _student_registration_form() {
$form['first_name'] = array(
'#type' => 'textfield',
'#title' => t('First Name'),
'#required' => TRUE,
);
$form['last_name'] = array(
'#type' => 'textfield',
'#title' => t('Last Name'),
'#required' => TRUE,
);
$form['send_query'] = array(
'#markup' => _actual_popup(),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
function _actual_popup() {
ctools_include('ajax');
ctools_include('modal');
ctools_modal_add_js();
$sample_style = array(
'ctools-sample-style' => array(
'modalSize' => array(
'type' => 'fixed',
'width' => 656,
'height' => 450,
'addWidth' => 20,
'addHeight' => 15,
),
'modalOptions' => array(
'opacity' => .5,
'background-color' => '#000',
),
'animation' => 'fadeIn',
'modalTheme' => 'CToolsSampleModal',
'throbber' => theme('image', array('path' => ctools_image_path('ajax-loader.gif', 'ctools_ajax_sample'), 'alt' => t('Loading...'), 'title' => t('Loading'))),
),
);
drupal_add_js($sample_style, 'setting');
ctools_add_js('ctools-ajax-sample', 'ctools_ajax_sample');
ctools_add_css('ctools-ajax-sample', 'ctools_ajax_sample');
$links = array();
$links[] = ctools_modal_text_button('Send query', 'query_custom/nojs/send', NULL, 'ctools-modal-ctools-sample-style');
$output = theme('item_list', array('items' => $links));
return $output ;
}
function _send_query_modal_box() {
global $base_url;
$submission = (object) array();
ctools_include('modal');
ctools_include('ajax');
$form_state = array(
'title' => t(''),
'ajax' => TRUE,
);
$form_state['build_info']['args'] = array();
$output = ctools_modal_form_wrapper('_send_query_form', $form_state);
if (!empty($form_state['executed'])) {
$output = array();
$output[] = ctools_modal_command_dismiss(t('Success!'));
}
print ajax_render($output);
exit;
}
function _send_query_form($form, &$form_state) {
$form= array();
$form['institute_name'] = array(
'#type' => 'select',
'#options' => array(
'abc_college' => t('ABC College'),
'def_college' => t('DEF College'),
'ghi_college' => t('GHI College'),
'klm_college' => t('KLM College'),
),
'#title' => t('Select school/college'),
);
$form['query_title'] = array(
'#type' => 'textfield',
'#title' => t('Query Information'),
'#required' => TRUE,
);
$form['message'] = array(
'#type' => 'textarea',
'#required' => TRUE,
'#title' => t('Query details'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit query'),
);
return $form;
}
5) Save this folder under 'example.com/site/all/module'(replace example with your domain name).
6) Enable this module at 'example.com/admin/modules'.
7) visit 'example.com/student_registration' to check the required feature(click on 'send query will open popup').
let me know if any query.
Tushar Bodake