[Drupal 7]How to hide the "URL path settings" fieldset?如何隐藏“URL别名”字段?

A number of Drupal users wanted to know how to hide the URL path settings fieldset in a Drupal 7 website. If you are a Drupal user facing the same question in your Drupal site with your Drupal Pathauto module even after using hook_form_alter then read on to find out the solution.

许多Drupal用户都知道在Drupal 7站点里隐藏URL路径设置,如果你也是一个在Drupal站点里应用了Drupal Pathauto模块,并遇到同样问题的Drupal用户,尽管在使用hook_form_alter之后仍然不起效果之后,可以看看下面的解决方案。

A hook_form_alter cannot be used to hide the URL path settings fieldset as the fieldset gets added in path_form_alter which runs after node_form_alter as both the modules have similar weight. To get around this you need to use a #after_build item in your form alter as shown below.

hook_form_alter勾子并不能被用于隐藏URL 路径设置,因为这个字段是path_form_alter里加入的,而这个path_form_alter是在node_form_alter之后被执行的,因为这两个模块(node,page)具有相同的权重。要避免这个问题,你需要在你的form alter里使用一个“#after_build” 项,参考下面的代码:

function custom_form_alter(&$form, &$form_state){
	$form['#after_build'][] = 'custom_after_build';
        ....
}
function custom_after_build($form, &$form_state) {
		$form['path']['#access'] = FALSE;
	$form['menu']['#access'] = FALSE;
	return ($form);	
} 

The above code will remove the form elements from the form after the build of the form is initialized.

上面的代码就可以在表单初始化完成并建立表单后移除表单元素,

Hope that helps.

希望有所帮助。

原文地址:

http://www.zyxware.com/articles/3567/drupal-pathauto-drupal-7-how-to-hide-the-url-path-settings-fieldset

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值