drupal - 更改模块中的视图

时间:2014-06-05 08:27:26

标签: php drupal drupal-7 drupal-modules drupal-views

我想根据Url更改模块的视图。全部用PHP。 我创建了两个放置此数据的视图:

function config_services_block_info() {   
 $blocks['config_services'] = array(
   // The name that will appear in the block list.
   'info' => t('Services'),
   // Default setting.
   'cache' => DRUPAL_CACHE_PER_ROLE,   );   
 $blocks['orderservices'] = array(
   // The name that will appear in the block list.
   'info' => t('Order Services'),
   // Default setting.
   'cache' => DRUPAL_CACHE_PER_ROLE,   );
 return $blocks; 
}

function config_services_block_view($delta = '') {   switch ($delta) {
  case 'config_services':
    ...
    block[content] = ...;
    return block;
  break;
  case 'orderservices':
    ...
    block[content] = ...;
    return block;
  break;   } }

function config_services_menu() {   $items = array();  
  $items['config_services/orderservices'] = array(
  'title' => t('Order Services'),
  'page callback' => array('_config_services_orderservices_page'),
  'access arguments' => array('order config_services content'),
  'type' => MENU_CALLBACK, //Will appear in block.   );   return $items; }

在_config_services_orderservices_page()中,我认为这样做但没有工作:

function _config_services_orderservices_page() {
  config_services_block_view('orderservices');
}

第一个视图有效,问题是我想要第二个视图。我如何更改URL的视图:http :(斜杠)(斜杠) name-web / config_services / orderservices

1 个答案:

答案 0 :(得分:0)

根据您要更改视图的条件,可以在_config_services_orderservices_page()函数内检查条件,并且可以显示特定的块。

function _config_services_orderservices_page() {
  if (your_condition == 'orderservices') {
    config_services_block_view('orderservices');
  }
  if (other_condition == 'config_services') {
    config_services_block_view('config_services');
  }
}

另一方面,Drupal中的 view 意味着完全不同的东西。它是整体上最受欢迎和最常用的模块。请访问project pagedocumentation 你所指的是关于blocks