Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
hi larowlan,
Thank you for all your advice really helped.
In fact i have a problem with adding extra fields to the search block.
Is it possible to have an example to add a "destination" field.
Please show me step by step from beginning to end.
I wait the answer impatiently.Thank's for all
Comments
Comment #1
larowlanHi
1) Create a module (you can use module_builder if you're not sure how to do this).
2) Create this (change YOURMODULENAME to the module's machine name)
3) enable the module
4) refine 2 until it works like you want
Devel module is your friend - you can use the dsm function to print the structure of $form and $form_state
Comment #2
larowlanComment #3
nazhamane CreditAttribution: nazhamane commentedHi larowlan ,
The second point is not clear :"2) Create this (change YOURMODULENAME to the module's machine name)"
After creating ""this"" what should be done- ? In which file should be put on and what name?
A lot of thanks
Comment #4
larowlanThe this goes in your module file - in the 'YOURMODULENAME.module' file
see http://drupal.org/node/206753 for more info
Comment #5
nazhamane CreditAttribution: nazhamane commentedHi larowlan ,
Please help I'm in trouble.I followed step by step all the points but nothing.
A sleepless night and nothing .Please show me step by step with precisions.
for the first point:
1-Create a module (you can use module_builder if you're not sure how to do this).
i use builder but i cannot use it with perfection (please show me how to do it)
2-Create this (change YOURMODULENAME to the module's machine name)
I'm lost in the middle of drupal.
Comment #6
larowlanPlease post what you've done so far
Comment #7
nazhamane CreditAttribution: nazhamane commentedHi larowlan
This is what I've done so far:
1. i go to /admin/build/module_builder Module builder
Machine-readable name : * i called it "destination"
Nom : * I called it "destination"
Description : * described it like this "Add extra fields to the search form"
Use the following specific hooks : I use ubercart hooks
i select all options :action_info #action_info_alter etc...
in the end i generate the module
I obtain this code for destination.module code :
<?php
// $Id$
/**
* @file
* TODO: Enter file description here.
*/
/**
* Implementation of hook_help().
*/
function destination_help($path, $arg) {
/* INFO:
* The help hook is for displaying helpful messages at the top of pages indicated
* by $section to further explain how they work. Adding certain "keywords" to the end of
* a given path (like admin/modules#description) will cause this text to display elsewhere
* in the page as well (in this case, in the description section for the given module).
*/
switch ($path) {
case 'admin/help#destination':
return t("TODO: Create admin help text.");
// OPTIONAL: Add additional cases for other paths that should display help text.
}
}
/**
* Implementation of hook_menu().
*/
function destination_menu() {
// This is the minimum information you can provide for a menu item.
$items['TODO: Enter path'] = array(
'title' => 'TODO: Enter menu item title',
'page callback' => 'TODO: Enter callback function',
'access arguments' => array('TODO: Enter user permissions'),
);
// more complex menu item
$items['TODO: Enter path'] = array(
'title' => 'TODO: Enter menu item title',
'description' => 'TODO: Enter description',
'page callback' => 'TODO: Enter callback function',
'page arguments' => '', // An array of arguments to pass to the page callback function. Integer values pass the corresponding URL component.
'access callback' => '', // defaults to user_access()
'access arguments' => array('TODO: Enter user permissions'),
'weight' => 0,
'type' => MENU_NORMAL_ITEM, // One of MENU_NORMAL_ITEM / MENU_CALLBACK / MENU_SUGGESTED_ITEM / MENU_LOCAL_TASK / MENU_DEFAULT_LOCAL_TASK
'menu_name' => '', // Menu to place this item in.
'title callback' => '', // Function to generate the title, defaults to t().
'title arguments' => '', // Arguments to send to t() or your custom callback.
);
// OPTIONAL: Fill in additional static menu items
return $items;
}
/**
* Implementation of hook_perm().
*/
function destination_perm() {
return array('create destination', 'edit own destination');
}
/**
* Implementation of hook_block().
*/
function destination_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Block 1');
$blocks[1]['info'] = t('Block 2');
// OPTIONAL: Add additional block descriptions here, if required.
return $blocks;
case 'configure':
// OPTIONAL: Enter form elements to add to block configuration screen, if required.
if ($delta == 0 && user_access('administer module')) {
$form['module_block_1'] = array();
}
if ($delta == 1 && user_access('administer module')) {
$form['module_block_2'] = array();
}
return $form;
case 'save':
// OPTIONAL: Add code to trigger when block configuration is saved, if required.
if ($delta == 0) {
variable_set('module_block_setting_1', $edit['module_block_1']);
}
if ($delta == 1) {
variable_set('module_block_setting_2', $edit['module_block_2']);
}
break;
case 'view':
if ($delta == 0) {
$block['subject'] = t('Block 1 title');
$block['content'] = t('Block 1 content');
}
if ($delta == 1) {
$block['subject'] = t('Block 2 title');
$block['content'] = t('Block 2 content');
}
// OPTIONAL: Enter additional cases for each additional block, if defined.
return $block;
}
}
/**
* Implementation of hook_link().
*/
function destination_link($type, $object, $teaser = FALSE) {
$links = array();
// TODO: Perform logic to determine when link should appear
$links['destination_KEY1'] = array( // a regular link
'title' => t('TODO: Fill in link title'),
'href' => 'TODO: Fill in link path',
'attributes' => array('title' => t('TODO: Fill in link title attribute.')),
);
$links['destination_KEY1'] = array( // a fake link that's just text
'title' => t('TODO: Fill in link title'),
'attributes' => array('title' => t('TODO: Fill in link title attribute.')),
);
$links['destination_KEY1'] = array( // a link that's we're sending as HTML
'title' => t('TODO: Fill in link HTML'),
'html' => TRUE,
);
// OPTIONAL: Add additional links
return $links;
}
/**
* Implementation of hook_nodeapi().
*/
function destination_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'alter':
// OPTIONAL: the $node->content array has been rendered, so the node body or
// teaser is filtered and now contains HTML. This op should only be used when
// text substitution, filtering, or other raw text operations are necessary.
break;
case 'delete':
// OPTIONAL: The node is being deleted.
break;
case 'delete revision':
// OPTIONAL: The revision of the node is deleted. You can delete data
// associated with that revision.
break;
case 'insert':
// OPTIONAL: The node is being created (inserted in the database).
break;
case 'load':
// OPTIONAL: The node is about to be loaded from the database. This hook
// can be used to load additional data at this time.
break;
case 'prepare':
// OPTIONAL: The node is about to be shown on the add/edit form.
break;
case 'prepare translation':
// OPTIONAL: The node is being cloned for translation. Load
// additional data or copy values from $node->translation_source.
break;
case 'print':
// OPTIONAL: Prepare a node view for printing. Used for printer-friendly
// view in book_module
break;
case 'rss item':
// OPTIONAL: An RSS feed is generated. The module can return properties
// to be added to the RSS item generated for this node. See comment_nodeapi()
// and upload_nodeapi() for examples. The $node passed can also be modified
// to add or remove contents to the feed item.
break;
case 'search result':
// OPTIONAL: The node is displayed as a search result. If you
// want to display extra information with the result, return it.
break;
case 'presave':
// OPTIONAL: The node passed validation and is about to be saved. Modules may
// use this to make changes to the node before it is saved to the database.
break;
case 'update':
// OPTIONAL: The node is being updated.
break;
case 'update index':
// OPTIONAL: The node is being indexed. If you want additional
// information to be indexed which is not already visible through
// nodeapi "view", then you should return it here.
break;
case 'validate':
// OPTIONAL: The user has just finished editing the node and is
// trying to preview or submit it. This hook can be used to check
// the node data. Errors should be set with form_set_error().
break;
case 'view':
// OPTIONAL: The node content is being assembled before rendering. The module
// may add elements $node->content prior to rendering. This hook will be
// called after hook_view(). The format of $node->content is the same as
// used by Forms API.
break;
}
}
/**
* Implementation of hook_elements().
*/
function destination_elements() {
$type['example'] = array('#property' => t('TODO: Fill in appropriate properties and values for element type.'));
// OPTIONAL: Define additional element types.
return $type;
}
/**
* Implementation of hook_filter().
*/
function destination_filter($op, $delta = 0, $format = -1, $text = '', $cache_id = 0) {
switch ($op) {
case 'list':
return array(t('TODO: Fill in name of filter.'));
case 'description':
return t('TODO: Fill in filter description.');
case 'no cache':
// TODO: This case can be removed for most filters, but returning TRUE is useful for development.
return FALSE;
case 'prepare':
return $text;
case 'process':
// TODO: Code function call for filter to run text through.
return;
case 'settings':
// OPTIONAL: Add additional settings for filter.
return;
}
}
/**
* Implementation of hook_filter_tips().
*/
function destination_filter_tips($delta, $format, $long = FALSE) {
// OPTIONAL: If more than one filter was defined in hook_filter, perform switch on $delta
switch ($long) {
case FALSE:
return t("TODO: Enter the filter's short-hand description");
case TRUE:
return t("TODO: Enter filter's full description");
}
}
/**
* Implementation of hook_theme().
*/
function destination_theme($existing, $type, $theme, $path) {
return array(
'my_simple_theme_function' => array(
'arguments' => array('arg1' => NULL, 'arg2' => 0, 'arg3' => FALSE),
),
);
}
/**
* Implementation of hook_action_info().
*/
function destination_action_info() {
}
/**
* Implementation of hook_actions_delete().
*/
function destination_actions_delete($aid) {
}
/**
* Implementation of hook_action_info_alter().
*/
function destination_action_info_alter(&$actions) {
}
/**
* Implementation of hook_comment().
*/
function destination_comment(&$a1, $op) {
}
/**
* Implementation of hook_cron().
*/
function destination_cron() {
}
/**
* Implementation of hook_hook_info().
*/
function destination_destination_info() {
}
/**
* Implementation of hook_menu_alter().
*/
function destination_menu_alter(&$items) {
}
/**
* Implementation of hook_menu_link_alter().
*/
function destination_menu_link_alter(&$item, $menu) {
}
/**
* Implementation of hook_translated_menu_link_alter().
*/
function destination_translated_menu_link_alter(&$item, $map) {
}
/**
* Implementation of hook_db_rewrite_sql().
*/
function destination_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
}
/**
* Implementation of hook_exit().
*/
function destination_exit($destination = NULL) {
}
/**
* Implementation of hook_file_download().
*/
function destination_file_download($filepath) {
}
/**
* Implementation of hook_footer().
*/
function destination_footer($main = 0) {
}
/**
* Implementation of hook_schema_alter().
*/
function destination_schema_alter(&$schema) {
}
/**
* Implementation of hook_form_alter().
*/
function destination_form_alter(&$form, &$form_state, $form_id) {
}
/**
* Implementation of hook_form_FORM_ID_alter().
*/
function destination_form_FORM_ID_alter(&$form, &$form_state) {
}
/**
* Implementation of hook_forms().
*/
function destination_forms($form_id, $args) {
}
/**
* Implementation of hook_boot().
*/
function destination_boot() {
}
/**
* Implementation of hook_init().
*/
function destination_init() {
}
/**
* Implementation of hook_link_alter().
*/
function destination_link_alter(&$links, $node, $comment = NULL) {
}
/**
* Implementation of hook_profile_alter().
*/
function destination_profile_alter(&$account) {
}
/**
* Implementation of hook_mail_alter().
*/
function destination_mail_alter(&$message) {
}
/**
* Implementation of hook_system_info_alter().
*/
function destination_system_info_alter(&$info, $file) {
}
/**
* Implementation of hook_update_status_alter().
*/
function destination_update_status_alter(&$projects) {
}
/**
* Implementation of hook_update_projects_alter().
*/
function destination_update_projects_alter(&$projects) {
}
/**
* Implementation of hook_node_grants().
*/
function destination_node_grants($account, $op) {
}
/**
* Implementation of hook_node_access_records().
*/
function destination_node_access_records($node) {
}
/**
* Implementation of hook_node_operations().
*/
function destination_node_operations() {
}
/**
* Implementation of hook_openid().
*/
function destination_openid($op, $request) {
}
/**
* Implementation of hook_ping().
*/
function destination_ping($name = '', $url = '') {
}
/**
* Implementation of hook_search().
*/
function destination_search($op = 'search', $keys = NULL) {
}
/**
* Implementation of hook_search_preprocess().
*/
function destination_search_preprocess($text) {
}
/**
* Implementation of hook_taxonomy().
*/
function destination_taxonomy($op, $type, $array = NULL) {
}
/**
* Implementation of hook_theme_registry_alter().
*/
function destination_theme_registry_alter(&$theme_registry) {
}
/**
* Implementation of hook_update_index().
*/
function destination_update_index() {
}
/**
* Implementation of hook_user().
*/
function destination_user($op, &$edit, &$account, $category = NULL) {
}
/**
* Implementation of hook_user_operations().
*/
function destination_user_operations() {
}
/**
* Implementation of hook_xmlrpc().
*/
function destination_xmlrpc() {
}
/**
* Implementation of hook_watchdog().
*/
function destination_watchdog($log_entry) {
}
/**
* Implementation of hook_mail().
*/
function destination_mail($key, &$message, $params) {
}
/**
* Implementation of hook_flush_caches().
*/
function destination_flush_caches() {
}
/**
* Implementation of hook_term_path().
*/
function destination_term_path($term) {
}
/**
* Implementation of hook_locale().
*/
function destination_locale($op = 'groups') {
}
/**
* Implementation of hook_translation_link_alter().
*/
function destination_translation_link_alter(&$links, $path) {
}
/**
* Implementation of hook_add_to_cart().
*/
function destination_add_to_cart($nid, $qty, $data) {
}
/**
* Implementation of hook_add_to_cart_data().
*/
function destination_add_to_cart_data($form_values) {
}
/**
* Implementation of hook_calculate_tax().
*/
function destination_calculate_tax($order) {
}
/**
* Implementation of hook_cart_display().
*/
function destination_cart_display($item) {
}
/**
* Implementation of hook_cart_pane().
*/
function destination_cart_pane($items) {
}
/**
* Implementation of hook_cart_pane_alter().
*/
function destination_cart_pane_alter(&$panes, $items) {
}
/**
* Implementation of hook_checkout_pane().
*/
function destination_checkout_pane() {
}
/**
* Implementation of hook_checkout_pane_alter().
*/
function destination_checkout_pane_alter(&$panes) {
}
/**
* Implementation of hook_download_authorize().
*/
function destination_download_authorize($user, $file_download) {
}
/**
* Implementation of hook_file_action().
*/
function destination_file_action($op, $args) {
}
/**
* Implementation of hook_file_transfer_alter().
*/
function destination_file_transfer_alter($file_user, $ip, $fid, $file) {
}
/**
* Implementation of hook_line_item().
*/
function destination_line_item() {
}
/**
* Implementation of hook_line_item_alter().
*/
function destination_line_item_alter(&$item, $order) {
}
/**
* Implementation of hook_line_item_data_alter().
*/
function destination_line_item_data_alter(&$items) {
}
/**
* Implementation of hook_order().
*/
function destination_order($op, $arg1, $arg2) {
}
/**
* Implementation of hook_order_actions().
*/
function destination_order_actions($order) {
}
/**
* Implementation of hook_order_product_alter().
*/
function destination_order_product_alter(&$product, $order) {
}
/**
* Implementation of hook_order_state().
*/
function destination_order_state() {
}
/**
* Implementation of hook_payment_gateway().
*/
function destination_payment_gateway() {
}
/**
* Implementation of hook_payment_gateway_alter().
*/
function destination_payment_gateway_alter(&$gateways) {
}
/**
* Implementation of hook_payment_method().
*/
function destination_payment_method() {
}
/**
* Implementation of hook_product_class().
*/
function destination_product_class($type, $op) {
}
/**
* Implementation of hook_product_description().
*/
function destination_product_description($product) {
}
/**
* Implementation of hook_product_description_alter().
*/
function destination_product_description_alter(&$description, $product) {
}
/**
* Implementation of hook_product_types().
*/
function destination_product_types() {
}
/**
* Implementation of hook_shipment().
*/
function destination_shipment($op, &$shipment) {
}
/**
* Implementation of hook_shipping_method().
*/
function destination_shipping_method() {
}
/**
* Implementation of hook_shipping_type().
*/
function destination_shipping_type() {
}
/**
* Implementation of hook_store_status().
*/
function destination_store_status() {
}
/**
* Implementation of hook_tapir_table_alter().
*/
function destination_tapir_table_alter(&$table, $table_id) {
}
/**
* Implementation of hook_tapir_table_header_alter().
*/
function destination_tapir_table_header_alter(&$header, $table_id) {
}
/**
* Implementation of hook_uc_checkout_complete().
*/
function destination_uc_checkout_complete($order, $account) {
}
/**
* Implementation of hook_uc_form_alter().
*/
function destination_uc_form_alter(&$form, &$form_state, $form_id) {
}
/**
* Implementation of hook_uc_invoice_templates().
*/
function destination_uc_invoice_templates() {
}
/**
* Implementation of hook_uc_message().
*/
function destination_uc_message() {
}
/**
* Implementation of hook_uc_payment_entered().
*/
function destination_uc_payment_entered($order, $method, $amount, $account, $data, $comment) {
}
/**
* Implementation of hook_uc_price_handler().
*/
function destination_uc_price_handler() {
}
/**
* Implementation of hook_uc_product_default_classes().
*/
function destination_uc_product_default_classes() {
}
/**
* Implementation of hook_uc_product_models().
*/
function destination_uc_product_models($node) {
}
/**
* Implementation of hook_uc_stock_adjusted().
*/
function destination_uc_stock_adjusted($sku, $stock, $qty) {
}
/**
* Implementation of hook_ucga_display().
*/
function destination_ucga_display() {
}
/**
* Implementation of hook_ucga_item_alter().
*/
function destination_ucga_item_alter(&$item, $product, $trans, $order) {
}
/**
* Implementation of hook_ucga_trans_alter().
*/
function destination_ucga_trans_alter(&$trans, $order) {
}
/**
* Implementation of hook_update_cart_item().
*/
function destination_update_cart_item($nid, $data = array(), $qty, $cid = NULL) {
}
And this for Module info :
; $Id$
name = destination
description = Add extra fields to the search form
core = 6.x
2. I copy and paste the following text into a file called destination.module and destination.info
3. I create a file called destination at sites/all/modules and insert the 2 files (destination.module and destination.info)
4 I go to /admin/build/modules and i enable destination module
after this i go to admin/store/settings/store i obtain this error:
Fatal error: Unsupported operand types in /var/www/clients/client0/web94/web/sites/all/modules/ubercart/uc_store/includes/uc_price.inc on line 181
Thanks for all