如何从 Drupal 视图中的表中的用户引用中添加带有 UID 的链接

发布于 2024-08-26 02:50:47 字数 528 浏览 7 评论 0原文

我在 Drupal 6 中有以下内容:

  1. 主 CCK 类型,其中包含用户参考字段和其他字段。这里每个用户只有一条记录。
  2. 此 CCK 的视图,显示为表格,其中字段之一是来自 CCK 类型的用户引用。该字段最初显示为用户名,链接到用户配置文件。
  3. 第二个 CCK 类型,可以包含有关特定用户的多条数据。
  4. 此 CCK 类型的视图,以表格形式显示信息。它将用户 ID 作为参数(整数)

我想单击主视图中的用户名,然后定向到该用户的详细视图。为此,我尝试在用户字段上选择“将此字段输出为链接”。我可以替换的内容是:

Fields
    * [field_my_user_ref_uid_1] == Content: User (field_my_user_ref)

Arguments
    * %1 == User: Uid

但是, [field_my_user_ref_uid_1] 元素被用户名替换,并且 %1 似乎被空字符串替换。我怎样才能把用户ID放在这里呢?

I have the following in Drupal 6:

  1. A Master CCK type which contains a User reference field and other fields. There will only be one record per user here.
  2. A View of this CCK, shown as a table, with one of the fields being the user ref from the CCK type. This field is initially shown as a user name, linking to the user profile.
  3. A Second CCK type which can have several pieces of data about a particular user.
  4. A View for this CCK type, displaying information as a table. It takes a user id as an argument (an integer)

I want to click on the user name in the master view, and be directed to the detail view for this user. To do this, I tried selecting 'Output this field as a link' on the user field. The thing available for me to replace are:

Fields
    * [field_my_user_ref_uid_1] == Content: User (field_my_user_ref)

Arguments
    * %1 == User: Uid

However, the [field_my_user_ref_uid_1] element is replaced by the user name, and %1 seems to get replaced with an empty string. How can I put the user id in here?

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

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

发布评论

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

评论(1

聽兲甴掵 2024-09-02 02:50:47

好吧,我不确定执行此操作的正确方法是什么,但我正在解决它,我似乎正在解决所有视图问题:通过向其抛出 jquery 。

目前,“用户引用”字段已经有一个与用户 ID 的链接,因此我已将其添加到页脚中:

<script type="text/javascript">
    $(function() {
        var $rows = $("table.views-table tbody tr");  
        $rows.children("td:nth-child(1)").each(function() {
            var $anchor = $(this).children("a");
            var linkElements = $anchor.attr("href").split("/");
            var userId = linkElements[linkElements.length - 1];
            $anchor.attr("href","/my_detail_view/" + userId);
        });
    });
</script>

我讨厌我必须这样做,但我确实喜欢 jquery。

Well, I'm not sure what the right way to do this is, but I'm solving it the hacky way I seem to be solving all my Views problems: by throwing jquery at it.

Currently, the User Ref field already has a link with the user id, so I've added this to the footer:

<script type="text/javascript">
    $(function() {
        var $rows = $("table.views-table tbody tr");  
        $rows.children("td:nth-child(1)").each(function() {
            var $anchor = $(this).children("a");
            var linkElements = $anchor.attr("href").split("/");
            var userId = linkElements[linkElements.length - 1];
            $anchor.attr("href","/my_detail_view/" + userId);
        });
    });
</script>

I hate that I have to do it like this, but I sure do love jquery.

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