In my drupal. I created a two theme one for desktop and another for mobile using Mobile switch I change the theme. Now I Created a View as a page for desktop with alias "xxx/yyy" and for mobile also I created a view as a page with same alias "xxx/yyy"(some modification Done). While switching the theme from desktop to mobile, the desktop view is appear. How to differentiate?
2 Answers
ok
create a menu with hook_menu then with checking condition you want load your views in callback of your menu
Something like below
/**
* Implements hook_menu().
*/
function mymodule_menu() {
$items['myurl'] = array(
'title' => 'title',
'page callback' => 'myfunction_callbackfuction',
'access callback' => TRUE,
);
return $items;
}
function myfunction_callbackfuction() {
$view = views_get_view('view_name');
if($mycondtion)
$view->set_display('page1');
else
$view->set_display('page2');
$view->pre_execute();
$view->execute();
print $view->render();
}
I achieve this by using
$view_name = 'my_views_name';
$display_id = 'my_views_display_id';
print views_embed_view($view_name , $display_id);