我现在正在阅读Pro Drupal开发,第82页的示例使用以下函数:
function menufun_menu_link_alter(&$item, $menu){
if ($item['link_path'] == 'logout'){
$item['link_title'] = 'Sign off';
}
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过查看api.drupal.org找出"hook_menu_link_alter"的参数.我不明白的是我应该如何找出$ item实际包含的内容.在这个例子中,$ item ['link_path']和$ item ['link_title']都被使用 - 他怎么知道它们存在?
当然,我不仅对这个具体的例子感兴趣.我希望能够为我在drupal中看到的任何函数执行此操作.
在此先感谢您的帮助!
我有几个自定义PHP函数,我想为我创建的几个模块提供这些函数.
什么是drupal正确的解决这个问题的方法?基本上,我想避免在我拥有的每个模块中复制所有这些功能.
在Drupal中添加分类术语时,它会重定向回自身以添加另一个术语.有没有办法压倒这个?
我到目前为止尝试过:
•将?destination = _添加到链接到/ add/term/page的页面
•尝试hook_taxonomy:
function modulename_taxonomy($op, $type, $array = NULL) {
if ($type == 'term' && ($op == 'insert' || $op == 'update') && $array['parent'][39] == 39) {
drupal_goto('page.html');
}
}
Run Code Online (Sandbox Code Playgroud)
如果不是drupal_goto()我把die('Here');它输出,但是drupal_goto()不起作用?
我正在尝试在我的模块中渲染一个包含表单和链接列表的块.我可以正确地显示一个或另一个,但显然不能很好地理解渲染数组格式,以便在同一个块中同时渲染它们(一个在另一个之上).使用Drupal 7.4
设置块内容以显示列表的示例:
$block['subject']='Title';
$items= // code that generates a list of links into an array
$theme_args=array('items'=>$items,'type'=>'ul');
$block['content']=theme('item_list',$theme_args);
return $block;
Run Code Online (Sandbox Code Playgroud)
设置块内容以显示表单的示例:
$block['subject']='Title';
$block['content']=drupal_get_form('mymodule_myform_function');
// call function that returns the usual form array
return $block;
Run Code Online (Sandbox Code Playgroud)
每个案例对我来说都很好.如何将表单和列表组合成一个块['content']数组,以便可以在一个块中呈现?提前致谢.
我正在更新我从D6写到D7的模块,因此必须通过新的#ajax表格交换旧的AHAH.
我正在执行一个ajax请求,它创建一个结果并用它替换一个表单元素.这基本上可以正常工作,但在第一次请求之后,结果会被缓存,并且不会考虑表单中的更改.我认为这可能是一个浏览器问题,但可能是Drupal发送了一个过期标头,导致浏览器采用缓存版本?还有其他想法吗?
hook_cache()中的片段:
$form['fieldset']['mybutton'] = array(
'#type' => 'button',
'#value' => t('Send request'),
'#ajax' => array(
'callback' => 'mycallback',
'wrapper' => 'mywrapper',
'method' => 'replace',
'effect' => 'fade',
)
Run Code Online (Sandbox Code Playgroud)
一个回调片段:
function mycallback($form, $form_state) {
[..]
$form['fieldset']['mywrapper']['#markup'] = 'test';
return $form['fieldset']['mywrapper']['#markup'];
}
Run Code Online (Sandbox Code Playgroud) 我有一个Drupal网站,它使用Quiz模块来管理访问者的测试.匿名用户需要使用这些测试.我的问题是我需要能够让考生输入姓名和电子邮件,以便将结果发送给他们.我只是不知道该怎么做.我认为自己是Drupal和PHP的初学者.任何帮助,将不胜感激.
有人可以指导我吗?
我有五个图像与我隐藏的节点相关联.我想在一个街区中展示它们.
如何在属于当前显示的节点的块中显示图像?那么当节点发生变化时,它会自动加载该节点上的图像?我认为这与添加过滤器有关.
但是,当我看到这些列表时,我似乎无法获得任何
"当前节点"过滤器.我还读到我可以将当前节点的参数传递给块.但是在drupal 7中,在编辑块时没有这样的字段称为"参数"....
谢谢
当用户点击前端的链接时,我想在弹出窗口中显示我的自定义表单,我尝试了很多在网络上显示的解决方案,但对我不起作用.
这是我的代码.
$response = new AjaxResponse();
// Get the modal form using the form builder.
$modal_form = $this->formBuilder->getForm('Drupal\fwsactions\Forms\FwsActionsForm');
$modal_form['#attached']['library'][] = 'core/drupal.dialog.ajax';
// Add an AJAX command to open a modal dialog with the form as the content.
$modal_form = render($modal_form);
$response->addCommand(new OpenModalDialogCommand('My Modal Form', $modal_form, ['width' => '800']));
return $response;
Run Code Online (Sandbox Code Playgroud)
如何通过单击链接打开此表单应该怎么做.
我正在尝试在基于 drupal 8 的网站中实现内容搜索功能。我正在使用搜索 API 模块进行内容搜索(https://www.drupal.org/project/search_api)我已经搜索了搜索 API 实现YouTube 上的视频。他们正在创建搜索索引并通过创建视图打印结果。我对内容的网址有疑问。如何获取结果的 url,以便我可以从搜索结果页面导航到该页面。另外,如果特定结果是一个块,我怎样才能获取页面 url?还有其他模块可以提供更好的功能吗?
当我运行drush有时我得到:"2个孤立的动作(comment_publish_action,comment_unpublish_action)存在于动作[警告]表中.删除孤立的动作"或类似的东西,是那个批评错误?或者我应该忽略它?那是什么意思?以及如何解决?
drupal-modules ×10
drupal ×9
php ×5
drupal-6 ×3
drupal-7 ×3
drupal-8 ×2
drupal-views ×1
drush ×1