Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Add custom table to views drupal 7?



Add custom table to views drupal 7?..

Answer / Balraj Singh

To add a custom table to Views in Drupal 7, follow these steps:nn1. Enable the Views module and the Views UI module if not already enabled.n2. Create a custom database table (using phpMyAdmin or Drush) with the necessary columns and data.n3. Implement hook_views_api() in your custom module to provide information about the new table:n```phpnfunction MYMODULE_views_api() {n return array('api' => 3, 'path' => drupal_get_path('module', 'my_module') . '/my_views.inc');}n```n4. Create a my_views.inc file in the specified path and implement hook_views_data() to define the new table and its fields:n```phpnfunction MYMODULE_views_data() {n $data = array();n $data['my_custom_table']['table']['group'] = t('Custom Tables');n $data['my_custom_table']['table']['base'] = array('alias' => 'my_table', 'title' => t('My Custom Table'));n $data['my_custom_table']['table']['fields']['field_1'] = array('id' => 'field_1', 'title' => t('Field 1'), 'help' => t('Description of Field 1'), 'field' => 'field_1');n // Add other fields as needed.n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Drupal Interview Questions

How to create drush command for your custom module?

1 Answers  


How does drupal scale?

1 Answers  


What is contextual filter?

1 Answers  


What is drupal and how do you use it?

1 Answers  


What database does drupal use?

1 Answers  


What is entity api ? Have you installed and worked on this module ?

1 Answers  


What is responsive theme?

1 Answers  


How do I show different drupal themes on different pages?

1 Answers  


What can you do with drupal?

1 Answers  


How do I remove the title 'navigation' from the navigation block?

1 Answers  


How to add more than one database in your code?

1 Answers  


What kind of support is available?

1 Answers  


Categories