Simple Block Module in Drupal 7
Create a simple module using the example on this link
http://harshal-techapps.blogspot.com/2011/03/simple-form-example-drupal-7-with.html
Then replace the deductible.module in that example with below.
This is the deductible.module
<?php
//;$Id$
/**
* @file
* Enables a single blog for an individual or multiple users.
*/
// After you learn Form API in Chapter 5, you'll be able to
// make these settings configurable.
function deductible_help($section) {
switch ($section) {
case 'admin/help#deductible':
return t('This module stores deductible for given make an Model');
}
}
function deductible_menu(){
$items['deductible/list']=array(
// 'title'=>'Calculate Deductible',
'page callback'=>'drupal_get_form',
'page arguments'=>array('display_list'),
'file'=> 'list.inc',
'access arguments' => array('administer user'),
);
$items['deductible/add_carrier']=array(
// 'title'=>'Calculate Deductible',
'page callback'=>'drupal_get_form',
'page arguments'=>array('addcarrier_form'),
'access arguments' => array('administer user'),
'file'=> 'carrier.inc',
//'type' => MENU_CALLBACK,
);
$items['deductible/calculate']=array(
// 'title'=>'Calculate Deductible',
'page callback'=>'drupal_get_form',
'page arguments'=>array('deductible_custom_form'),
'access arguments' => array('administer user'),
'file'=> 'deductibleadd.inc',
// 'type' => MENU_CALLBACK,
);
//watchdog('Deductibe', '1', array(), WATCHDOG_DEBUG);
$items['deductible/display_results'] = array(
// 'title'=>'Calculate Deductible',
'access arguments' => array('administer user'),
'page callback' => 'display_results',
'access callback' => TRUE,
//'type' => MENU_CALLBACK,
);
$items['deductible/delete/%'] = array(
// 'title'=>'Calculate Deductible',
'access arguments' => array('administer user'),
'page callback' => 'delete_item',
'access callback' => TRUE,
'page arguments' => array(0,1,2),
'file'=> 'deductibledelete.inc',
//'type' => MENU_LOCAL_TASK,
);
//watchdog('Deductibe', '2', array(), WATCHDOG_DEBUG);
return $items;
}
/**
* Implementation of hook_perm().
*/
function deductible_permission() {
return array('administer user');
}
function display_results()
{
$result = db_query("SELECT itemid,make,model,deductible FROM {Deductible}");
$listitems=array();
$bigitems = array();
foreach ($result as $item) {
watchdog('Deductibe', 'hi', array(), WATCHDOG_DEBUG);
$listitems=array($item->make,
$item->model,
$item->deductible,
l('Delete','deductible/delete/'.$item->itemid),
l('Update','deductible/update/'.$item->itemid)
);
$bigitems[]=$listitems;
}
// return print_r($bigitems);
if (count($listitems) == 0)
$make[] = array("No Models Entered Yet");
else{
watchdog('Deductibe', 'a', array(), WATCHDOG_DEBUG);
}
$link_to_add_form = l('Add More Models','deductible/calculate');
$variable=array(
'header' => array(t('Make'), t('Model'),t('Deductible'),t('Delete'),t('Update')),
'rows' => $bigitems,
'attributes' => array(),
'caption' => NULL,
'colgroups' => NULL,
'sticky' => NULL,
'empty' => NULL,
);
// return print_r($items);
return theme_table($variable).'<br/>'.$link_to_add_form;
}
function theme_deductible($form) {
watchdog('Deductibe', 'abf', array(), WATCHDOG_DEBUG);
$output = drupal_render($form['Title']);
return $output;
}
function deductible_theme($existing, $type, $theme, $path) {
return array(
'deductible' => array(
'arguments' => array('form' => NULL),
'template' => 'deductible',
'render element' => 'form',
'file'=> 'deductibleadd.inc',
),
'list' => array(
'arguments' => array('form' => NULL),
'template' => 'list',
'render element' => 'form',
),
'carrier' => array(
'arguments' => array('form' => NULL),
'template' => 'carrier',
'render element' => 'form',
),
);
}
function deductible_block_info() {
$blocks = array();
// The array key defines the $delta parameter used in all
// other block hooks.
$blocks['list'] = array(
// The name of the block on the blocks administration page.
'info' => t('List'),
'file'=>'list.inc',
);
return $blocks;
}
function deductible_block_view($delta = '') {
$block = array();
switch ($delta) {
case "list":
$form = drupal_get_form('display_list');
$block["content"] = $form;
break;
}
return $block;
}
function display_list(){
$form = array();
$path = drupal_get_path('module', 'Deductible');
$form['#attached'] = array
(
'css' => array
(
'type' => 'file',
'data' => $path . '/root.css',
),
'js' => array
(
'type' => 'file',
'data' => $path . '/root.js',
),
);
$form['#theme'] = 'list';
return $form;
}
Create a simple module using the example on this link
http://harshal-techapps.blogspot.com/2011/03/simple-form-example-drupal-7-with.html
Then replace the deductible.module in that example with below.
This is the deductible.module
<?php
//;$Id$
/**
* @file
* Enables a single blog for an individual or multiple users.
*/
// After you learn Form API in Chapter 5, you'll be able to
// make these settings configurable.
function deductible_help($section) {
switch ($section) {
case 'admin/help#deductible':
return t('This module stores deductible for given make an Model');
}
}
function deductible_menu(){
$items['deductible/list']=array(
// 'title'=>'Calculate Deductible',
'page callback'=>'drupal_get_form',
'page arguments'=>array('display_list'),
'file'=> 'list.inc',
'access arguments' => array('administer user'),
);
$items['deductible/add_carrier']=array(
// 'title'=>'Calculate Deductible',
'page callback'=>'drupal_get_form',
'page arguments'=>array('addcarrier_form'),
'access arguments' => array('administer user'),
'file'=> 'carrier.inc',
//'type' => MENU_CALLBACK,
);
$items['deductible/calculate']=array(
// 'title'=>'Calculate Deductible',
'page callback'=>'drupal_get_form',
'page arguments'=>array('deductible_custom_form'),
'access arguments' => array('administer user'),
'file'=> 'deductibleadd.inc',
// 'type' => MENU_CALLBACK,
);
//watchdog('Deductibe', '1', array(), WATCHDOG_DEBUG);
$items['deductible/display_results'] = array(
// 'title'=>'Calculate Deductible',
'access arguments' => array('administer user'),
'page callback' => 'display_results',
'access callback' => TRUE,
//'type' => MENU_CALLBACK,
);
$items['deductible/delete/%'] = array(
// 'title'=>'Calculate Deductible',
'access arguments' => array('administer user'),
'page callback' => 'delete_item',
'access callback' => TRUE,
'page arguments' => array(0,1,2),
'file'=> 'deductibledelete.inc',
//'type' => MENU_LOCAL_TASK,
);
//watchdog('Deductibe', '2', array(), WATCHDOG_DEBUG);
return $items;
}
/**
* Implementation of hook_perm().
*/
function deductible_permission() {
return array('administer user');
}
function display_results()
{
$result = db_query("SELECT itemid,make,model,deductible FROM {Deductible}");
$listitems=array();
$bigitems = array();
foreach ($result as $item) {
watchdog('Deductibe', 'hi', array(), WATCHDOG_DEBUG);
$listitems=array($item->make,
$item->model,
$item->deductible,
l('Delete','deductible/delete/'.$item->itemid),
l('Update','deductible/update/'.$item->itemid)
);
$bigitems[]=$listitems;
}
// return print_r($bigitems);
if (count($listitems) == 0)
$make[] = array("No Models Entered Yet");
else{
watchdog('Deductibe', 'a', array(), WATCHDOG_DEBUG);
}
$link_to_add_form = l('Add More Models','deductible/calculate');
$variable=array(
'header' => array(t('Make'), t('Model'),t('Deductible'),t('Delete'),t('Update')),
'rows' => $bigitems,
'attributes' => array(),
'caption' => NULL,
'colgroups' => NULL,
'sticky' => NULL,
'empty' => NULL,
);
// return print_r($items);
return theme_table($variable).'<br/>'.$link_to_add_form;
}
function theme_deductible($form) {
watchdog('Deductibe', 'abf', array(), WATCHDOG_DEBUG);
$output = drupal_render($form['Title']);
return $output;
}
function deductible_theme($existing, $type, $theme, $path) {
return array(
'deductible' => array(
'arguments' => array('form' => NULL),
'template' => 'deductible',
'render element' => 'form',
'file'=> 'deductibleadd.inc',
),
'list' => array(
'arguments' => array('form' => NULL),
'template' => 'list',
'render element' => 'form',
),
'carrier' => array(
'arguments' => array('form' => NULL),
'template' => 'carrier',
'render element' => 'form',
),
);
}
function deductible_block_info() {
$blocks = array();
// The array key defines the $delta parameter used in all
// other block hooks.
$blocks['list'] = array(
// The name of the block on the blocks administration page.
'info' => t('List'),
'file'=>'list.inc',
);
return $blocks;
}
function deductible_block_view($delta = '') {
$block = array();
switch ($delta) {
case "list":
$form = drupal_get_form('display_list');
$block["content"] = $form;
break;
}
return $block;
}
function display_list(){
$form = array();
$path = drupal_get_path('module', 'Deductible');
$form['#attached'] = array
(
'css' => array
(
'type' => 'file',
'data' => $path . '/root.css',
),
'js' => array
(
'type' => 'file',
'data' => $path . '/root.js',
),
);
$form['#theme'] = 'list';
return $form;
}
Great blοg! Do уοu have any
ReplyDeletetiρѕ and hints for aspiring ωгiterѕ?
I'm planning to start my own blog soon but I'm a littlе lost οn evеrything.
Would yоu recommend starting with a frеe platfοrm lіke
Wordpreѕs oг go fοr а pаiԁ option?
Тheгe aге so many
ορtionѕ оut there thаt Ι'm totally confused .. Any suggestions? Appreciate it!
Stop by my web-site; raspberry ketone
An imprеsѕive share! I have just forwаrdеd this οnto a сolleague ωho had been conducting a little
ReplyDeletehοmeωork on thiѕ. And he in fact ordeгeԁ me
ԁinnеr due to the fact that I stumbled upon
it foг him... lοl. Ѕο allow me to reωord thiѕ.
... Thanks for the meal!! Βut yeah, thanks for spending some time to talκ abοut this issuе heге on уour
wеbsite.
My blog post :: http://rayoroa.cs.umss.edu.bo/
Woah! I'm really enjoying the template/theme of this blog. It's simple,
ReplyDeleteyet effective. A lot of times it's hard to get that "perfect balance" between user friendliness and visual appeal. I must say that you've done a amazing
job with this. In addition, the blog loads super fast for
me on Chrome. Superb Blog!
Here is my site; Http://10Ztalk.Com/ElizaPeel
Thankfulness to my father who told me concerning this weblog, this web site is truly remarkable.
ReplyDeleteMy web-site :: http://mashwaraworld.com/groups/wasserfeste-mp3-player-Zum-schwimmen
I've been browsing online more than 3 hours today, yet I never found any interesting article like yours. It's pretty worth
ReplyDeleteenough for me. In my opinion, if all web owners and bloggers
made good content as you did, the net will be much more
useful than ever before.
Here is my homepage ... mp3 player usb - http://v9.water.cc/admin/donations/ipod-itouch-5g-relase-stories-well-grounds-reviews -
It's actually a cool and helpful piece of info. I'm satisfied that you simply shared this helpful information with us.
ReplyDeletePlease stay us informed like this. Thank you for sharing.
Here is my web site; gartenteichfilter selber bauen