I have a need to display views using an old Drupal database. These views are already created, so I exported them and dropped the export code into a custom module hook_views_default_view
, put in the necessary return
, changed the view name, updated the paths, etc. So, now I have two Views showing exactly the same dataset.
I need the newly created one to query against an old database; both databases have exactly the same structure. I have the old database setup in settings.php and, I thought, all I needed to do was add $view->database = "oldlife"
. That's not working - I'm getting the exact same data in both views (two different paths).
This is the code, minus all the handlers and unnecessary stuff:
function lwg_old_db_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'lwg_old_db'),
);
}
function lwg_old_db_views_default_views() {
$view = new view();
$view->name = 'commerce_vbo_views_orders_oldlife';
$view->description = 'Display a list of orders for the store admin.';
$view->tag = 'commerce';
$view->database = 'oldlife';
$view->base_table = 'commerce_order';
$view->human_name = 'Orders';
$view->core = 0;
$view->api_version = '3.0';
$view->disabled = FALSE;
/**
* many lines of $handler-> stuff
*/
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->display->display_options['path'] = 'list-all-nodes';
$views[$view->name] = $view;
return $views;
}
$view->database
is used everywhere within the view when processing queries? Dooldlife
andolddb
need to match?$view->database
was even a thing, I'm digging through the API now.oldlife
is the correct name of the database connection in settings.php, I was wrong in the question text, I'll edit it now.