Posted by bharathkanichar on September 25, 2010 at 11:13am
i have two websites installed on two different databases,now i want to
create a view from these two data bases and show as a home page
i have two websites installed on two different databases,now i want to
create a view from these two data bases and show as a home page
Comments
Solution
First of all these two bases should be Drupal databases.
Second, settings.php file should be like that:
$db_url['default'] = 'mysql://username:password@localhost/databasename1';
$db_url['second_base'] = 'mysql://username:password@localhost/databasename2';
Third, it`s actually code:
<?php
$first_view = views_embed_view('view_name_from_first_base', 'display_name');
db_set_active('second_base');
$second_view = views_embed_view('view_name_from_second_base', 'display_name');
db_set_active('default');
$output = $first_view . $second_view;
// TODO: theming, etc...
?>
Although this could work, you should check everything correctly to get rid of any errors.