[英]drupal - Change the view in the module
I want to change the view of the module depending on the Url. 我想根据网址更改模块的视图。 All in php. 所有在PHP。 I created two views putting this data: 我创建了两个放置此数据的视图:
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; }
In _config_services_orderservices_page() I think this but no work: 在_config_services_orderservices_page()中,我认为这是没有用的:
function _config_services_orderservices_page() {
config_services_block_view('orderservices');
}
The first view works, the problem is when I want the second view. 第一个视图有效,问题是当我想要第二个视图时。 How I change the view for the url: http:(slash)(slash) name-web /config_services/orderservices 我如何更改URL的视图:http :(斜杠)(斜杠) name-web / config_services / orderservices
Depending on the condition you want to change the view, the condition could be checked inside _config_services_orderservices_page()
function, and specific block could be displayed. 根据您要更改视图的条件,可以在_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');
}
}
On a side note, view in Drupal means something totally different. 附带一提,Drupal中的视图意味着完全不同的东西。 It is the most popular and most used module overall. 总体而言,它是最流行和最常用的模块。 Please visit the project page , and the documentation . 请访问项目页面和文档 。
And what you refer to is about blocks . 您所指的是关于块的 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.