Rumah  >  Artikel  >  pembangunan bahagian belakang  >  关于向drupal中添加js的有关问题

关于向drupal中添加js的有关问题

WBOY
WBOYasal
2016-06-13 10:38:04843semak imbas

关于向drupal中添加js的问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//请问大家有熟悉drupal的吗?我想在user.module中的user_authenticate函数中插入一段script,请问如何做?function user_authenticate($name, $pass) {  global $user;  // Try to log in the user locally. Don't set $user unless successful.  if ($account = user_load(array('name' => $name, 'pass' => $pass, 'status' => 1))) {    // Check if the e-mail is denied by an access rule.    // Doing this check here saves us a user_load() in user_login_validate()    // and introduces less code change for a security fix.    if (drupal_is_denied('mail', $account->mail)) {      form_set_error('name', t('The name %name is registered using a reserved e-mail address and therefore could not be logged in.', array('%name' => $account->name)));      return;    }    else {//我想在登陆成功后在这里插入一段script,请问如何插入,试了一个晚上,用drupal_add_js总是不行      $user = $account;       return $user;    }  }


------解决方案--------------------
楼主真逗!~

PHP是服务器语言 JS是客户端语言 怎可同日而语?
除非你将JS设置成Server 或者 在PHP中用上echo('');输出到客户端运行
------解决方案--------------------
你要插入什么JS?
echo '';
------解决方案--------------------
探讨
引用:
你要插入什么JS?
echo ' ';

我以前就是这么写的,但在user.module中使用echo是不行的,所以才来问的

------解决方案--------------------
加了JS后,面页有没有说面页有错误之类的东东?
------解决方案--------------------
那考虑用层来做提示吧!
echo "这里插入提示之类语言!";

------解决方案--------------------
那这样呢
else {
?>
 

 $user = $account;

------解决方案--------------------
探讨
在user.module中使用Echo script后,在用户登陆后,则变成第一屏是白屏,再刷一次,才能到正常页面

------解决方案--------------------
drupal在国内的普及度本来就不高,何不到drupal.org的论坛去问问呢?
------解决方案--------------------
探讨
引用:
你要插入什么JS?
echo ' ';

我以前就是这么写的,但在user.module中使用echo是不行的,所以才来问的

------解决方案--------------------
请问楼主的qq是多少啊告诉我
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn