Ege*_*can 15 drupal drupal-views drupal-6 drupal-exposed-filter
我创建了一个有三个暴露过滤器的视图.一切正常,除了我无法翻译或更改下拉列表的默认字符串(-Any-)这一事实.有没有办法将此字符串更改为更有意义的内容,如"请选择"并使其可翻译,以便德语版本显示"Bittewählen"?我有两个可能有用的屏幕截图:
和
进一步的改进是能够将文本"任何"更改为"请选择一个(此处的字段名称)",但我对此失去了希望=)
小智 23
对于任何想要将" - Any - "的值更改为特定内容的人,请使用自定义模块覆盖如下所示:
function yourmodulename_form_alter(&$form, $form_state, $form_id) {
if($form_state['view']->name == 'your_view_name_here') {
$form['your_dropdown_name']['#options']['All'] = t('- Type -'); // overrides <All> on the dropdown
}
}
Run Code Online (Sandbox Code Playgroud)
您可能希望这样做的原因是,如果您有3个(例如)3个单独字段的下拉列表.然后使用它们对用户来说不是很有用(特别是如果你没有使用标签).
在上面的代码中,只需记住将"yourmodulename"更改为模块的名称.
your_view_name_here应该是您的视图的名称(用下划线替换破折号 - 例如"property-search-bar"将变为"property_search_bar")
并将"your_dropdown_name"更改为字段名称 - 我通过使用安装并启用dsm($form)
了devel模块来找到它.这通常是您下拉列表的字段名称,因此它可能类似于"field_my_custom_value".
希望这可以帮助任何需要它的人!
三种选择:
在Drupal 7中(Drupal6仅在细节上有所不同)
/**
* String overrides:
*
* To override specific strings on your site with or without enabling locale
* module, add an entry to this list. This functionality allows you to change
* a small number of your site's default English language interface strings.
*
* Remove the leading hash signs to enable.
*/
$conf['locale_custom_strings_en'][''] = array(
'<Any>' => 'Whatever!',
);
Run Code Online (Sandbox Code Playgroud)
但请注意,这将改变完整字符串(区分大小写)的每个<Any>
出现Whatever
,而不仅仅是单个形式的字符串.