Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 12 characters in body; edited tags; edited title
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

Custom How to display custom table data inside views drupal 7?

And in same module, created form for reading inputs from user and a submit handler for inserting those values inside this schema. It works fine. But now I need to fetch the data and display in View3Views. How can I do that.? I have created a hook_views_api as:

but now this is not showing up in Add View. What else iI have missed. Please help. Thanks in advance. Am? I am searching this days and today its dead line for finishing this. Please need some immediate help on this.

Custom table data inside views drupal 7

And in same module, created form for reading inputs from user and a submit handler for inserting those values inside this schema. It works fine. But now I need to fetch the data and display in View3. How can I do that. I have created a hook_views_api as:

but now this is not showing up in Add View. What else i have missed. Please help. Thanks in advance. Am searching this days and today its dead line for finishing this. Please need some immediate help on this.

How to display custom table data inside views?

And in same module, created form for reading inputs from user and a submit handler for inserting those values inside this schema. It works fine. But now I need to fetch the data and display in Views. How can I do that? I have created a hook_views_api as:

but now this is not showing up in Add View. What else I have missed? I am searching this days and today its dead line for finishing this. Please need some help on this.

edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Source Link

Custom table data inside views drupal 7

I have a custom table created using .install file in my custom module.

+---------------+------------------+------+-----+---------+----------------+
| Field         | Type             | Null | Key | Default | Extra          |
+---------------+------------------+------+-----+---------+----------------+
| id            | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| first_name    | varchar(255)     | NO   |     | NULL    |                |
| last_name     | varchar(255)     | YES  |     | NULL    |                |
| email_address | varchar(255)     | NO   |     | NULL    |                |
| user_country  | varchar(50)      | NO   |     | NULL    |                |
| user_city     | varchar(50)      | NO   |     | NULL    |                |
| address       | varchar(600)     | NO   |     | NULL    |                |
| gender        | varchar(10)      | NO   |     | NULL    |                |
+---------------+------------------+------+-----+---------+----------------+

And in same module, created form for reading inputs from user and a submit handler for inserting those values inside this schema. It works fine. But now I need to fetch the data and display in View3. How can I do that. I have created a hook_views_api as:

   function MY_MODULE_views_api() {
  return array(
    ‘api’ => 3,
  );
}

In hook_view_data(),

<?php
function my_module_views_data()
{
$data=array();

 $data['myuser']['id'] = array(
    'title' => t('id'),
    'help' => t('Just a numeric field.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  
$data['myuser']['first_name'] = array(
    'title' => t('First Name'), 
    'help' => t('To get first Name.'), 
    'field' => array(
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE,
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ), 
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

$data['myuser']['last_name'] = array(
    'title' => t('last Name'), 
    'help' => t('To get last Name.'), 
    'field' => array(
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE,
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ), 
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );
  
$data['myuser']['email_address'] = array(
    'title' => t('Email Address'), 
    'help' => t('To get Email Address.'), 
    'field' => array(
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE,
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ), 
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );
  
$data['myuser']['user_country'] = array(
    'title' => t('User Country'), 
    'help' => t('To get User Country.'), 
    'field' => array(
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE,
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ), 
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

$data['myuser']['user_city'] = array(
    'title' => t('User City'), 
    'help' => t('To get User City.'), 
    'field' => array(
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE,
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ), 
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );
  
 $data['myuser']['address'] = array(
    'title' => t('Address'), 
    'help' => t('To get ADdress.'), 
    'field' => array(
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE,
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ), 
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),  
  );
  
 $data['myuser']['gender'] = array(
    'title' => t('Gender'), 
    'help' => t('To get Gender.'), 
    'field' => array(
      'handler' => 'views_handler_field', 
      'click sortable' => TRUE,
    ), 
    'sort' => array(
      'handler' => 'views_handler_sort',
    ), 
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ), 
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

}

but now this is not showing up in Add View. What else i have missed. Please help. Thanks in advance. Am searching this days and today its dead line for finishing this. Please need some immediate help on this.