drupal中如何更改评论表单的标题

发布于 2024-10-25 17:51:21 字数 184 浏览 3 评论 0原文

在我的网站上有“登录或注册才能发表评论..”

我想将消息更改为: “登录或注册才能发表评论(评论将受到审核)..”

因为大量垃圾邮件发送者只是创建登录名来发布垃圾评论。 尽管现在所有评论都经过审核。放置此消息将提供明确的信息,表明垃圾邮件可能是不可能的,并且垃圾邮件发送者不会创建登录名。

At my website there is "Login or register to post comments.."

I want to change the message to:
"Login or register to post comments(comments will be moderated).."

Because plenty of spammers are just creating logins to post spam comments.
Although all comments are moderated now. Putting this message will give clear info that spamming may not be possible and spammers will not create logins.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

千秋岁 2024-11-01 17:51:21

假设您使用的是 Drupal 6,创建评论表单的代码位于 Drupal 模块目录中的 comments.module 文件中。幸运的是,该函数允许主题化。

您可以做的就是复制并粘贴函数 theme_comment_post_forbidden($node) 并将其放置在主题目录中的 template.php 文件中。您还需要重命名该函数,将“主题”替换为您的主题名称。

例如,假设您的主题名称是“utilitiesindia”。然后,您将函数重命名为utilitiesindia_comment_post_forbidden。

因此,在名为utilitiesindia 的主题中的template.php 文件中,使用以下函数:

/**
 * Theme a "you can't post comments" notice.
 *
 * @param $node
 *   The comment node.
 * @ingroup themeable
 */
function utiltiesindia_comment_post_forbidden($node) {
  global $user;
  static $authenticated_post_comments;

  if (!$user->uid) {
    if (!isset($authenticated_post_comments)) {
      // We only output any link if we are certain, that users get permission
      // to post comments by logging in. We also locally cache this information.
      $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));
    }

    if ($authenticated_post_comments) {
      // We cannot use drupal_get_destination() because these links
      // sometimes appear on /node and taxonomy listing pages.
      if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
        $destination = 'destination='. rawurlencode("comment/reply/$node->nid#comment-form");
      }
      else {
        $destination = 'destination='. rawurlencode("node/$node->nid#comment-form");
      }

      if (variable_get('user_register', 1)) {
        // Users can register themselves.
        return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments(comments will be moderated)', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination)))
);
      }
      else {
        // Only admins can add new users, no public registration.
        return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
      }
    }
  }
}

Assuming you are using Drupal 6, the code that creates the comment form is in the file comments.module in the Drupal module directory. Fortunately, the function allows for theming.

What you can do is copy and paste the function theme_comment_post_forbidden($node) and place it in the template.php file in your theme directory. You will also need to rename the function, replacing 'theme' with your theme name.

For example, say your theme name is 'utilitiesindia'. Then you will rename your function to utilitiesindia_comment_post_forbidden.

So, in your template.php file in a theme named utilitiesindia, use this function:

/**
 * Theme a "you can't post comments" notice.
 *
 * @param $node
 *   The comment node.
 * @ingroup themeable
 */
function utiltiesindia_comment_post_forbidden($node) {
  global $user;
  static $authenticated_post_comments;

  if (!$user->uid) {
    if (!isset($authenticated_post_comments)) {
      // We only output any link if we are certain, that users get permission
      // to post comments by logging in. We also locally cache this information.
      $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));
    }

    if ($authenticated_post_comments) {
      // We cannot use drupal_get_destination() because these links
      // sometimes appear on /node and taxonomy listing pages.
      if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
        $destination = 'destination='. rawurlencode("comment/reply/$node->nid#comment-form");
      }
      else {
        $destination = 'destination='. rawurlencode("node/$node->nid#comment-form");
      }

      if (variable_get('user_register', 1)) {
        // Users can register themselves.
        return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments(comments will be moderated)', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination)))
);
      }
      else {
        // Only admins can add new users, no public registration.
        return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
      }
    }
  }
}
还在原地等你 2024-11-01 17:51:21

在 Drupal 6 中:
另一种选择是创建一个小型自定义模块。这使用 hook_link_alter() 。这是一个小示例模块,用于更改“登录以发布新评论”链接的标题:(将 MYMODULE_NAME 的每个实例替换为您为模块选择的名称)

第 1 步:创建一个名为 MYMODULE_NAME.info 的文件并添加:

; $Id$
name = "MYMODULE_NAME"
description = "Change the appearance of links that appear on nodes"
core = 6.x

STEP 2:创建名为 MYMODULE_NAME.module 的文件并添加:

<?php
  // $Id$;

  /**
   * Implementation of hook_link_alter
   */
  function MYMODULE_NAME_link_alter(&$links, $node){
    if (!empty($links['comment_forbidden'])) {
      // Set "Login to post new comment" link text
      $links['comment_forbidden']['title'] = 'NEW TEXT';

      // Add this to allow HTML in the link text
      $links['comment_forbidden']['html'] = TRUE;
    }
  }

步骤 3:将这些文件放入名为 MYMODULE_NAME 的文件夹中,将该文件夹放在sites/all/modules 中,然后启用该模块

In Drupal 6:
Another option is to create a small custom module. This uses hook_link_alter(). This is a small example module to change the title of the "Login to post new comment" link: (Replace every instance of MYMODULE_NAME with the name you choose for the module)

STEP 1: Create a file called MYMODULE_NAME.info and add:

; $Id$
name = "MYMODULE_NAME"
description = "Change the appearance of links that appear on nodes"
core = 6.x

STEP 2: Create file called MYMODULE_NAME.module and add:

<?php
  // $Id$;

  /**
   * Implementation of hook_link_alter
   */
  function MYMODULE_NAME_link_alter(&$links, $node){
    if (!empty($links['comment_forbidden'])) {
      // Set "Login to post new comment" link text
      $links['comment_forbidden']['title'] = 'NEW TEXT';

      // Add this to allow HTML in the link text
      $links['comment_forbidden']['html'] = TRUE;
    }
  }

STEP 3: Put these files in a folder called MYMODULE_NAME, place the folder in sites/all/modules, and enable the module

木槿暧夏七纪年 2024-11-01 17:51:21

如果您确实想阻止垃圾邮件发送者创建帐户,您应该使用验证码模块之类的东西,因为他们通常使用在任何情况下都会忽略指令的机器人。

http://drupal.org/project/captcha

If you actually want to stop spammers from creating accounts, you should use something like the CAPTCHA module, since they typically use bots that will ignore instructions in any case.

http://drupal.org/project/captcha

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文