我有一个视图(phase4),其中包含一些自定义内容类型的内容,用户可以在其中进行评论。
当用户想要评论时,评论表单应该以模态表单的形式出现。我用admin overlay解决了这个问题。将以下函数添加到我的自定义模块中:
function phase2_admin_paths_alter(&$paths) {
$paths['comment/reply/*'] = TRUE;
}并使用以下链接:
<a href="<?php print base_path(); ?>comment/reply/<?php print $fields['nid']->content; ?>">Comment</a>以模式方式打开备注表单。到目前为止一切顺利..。但是...
如何将用户重定向回该用户所在的页面。我知道我必须在template_form_FORMID_alter中重写表单的#action,比如
$form['#action'] = $lasturl;但是如何获取最后的url,使其可重用(所以不能对url进行硬编码)?
我的第一个想法是通过将最后一个url作为$_GET参数添加到url中来传输它,但它看起来像这样:
www.example.com/phase4#overlay=comment/reply/161%3Furl%3Dphase4我也尝试过使用drupal_get_destination(),但都没有成功,因为"?“和url中的"=“。
有没有其他方法来找出用户来自哪里?
注意: phase4不是节点161的别名。阶段4是一个视图,其中节点161是的元素。
干杯汤姆
发布于 2013-07-27 22:44:49
您必须使用带有l()函数的drupal_get_destination()函数来创建此类链接。
$destination = drupal_get_destination(); // Store current path
<a href="<?php print base_path(); ?>comment/reply/<?php print $fields['nid']->content . "?destination=".$destination; ?>">Comment</a>https://stackoverflow.com/questions/17830526
复制相似问题