Drupal Views:在个人资料页面上显示用户最近创建的节点

发布于 2024-08-27 08:56:50 字数 83 浏览 7 评论 0原文

我想知道如何在用户的个人资料页面上显示用户最近创建的节点。我已经在 /user/%user 为用户创建了一个新页面,我希望能够显示该用户创建的最新节点。

I'm wondering how I can display the recently created nodes by a user on their profile page. I've created a new page for a user at /user/%user and I want to be able to display the latest nodes created by that user.

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

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

发布评论

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

评论(3

我纯我任性 2024-09-03 08:56:50

好的,答案涉及创建一个 drupal 视图,因此您将需要 views 模块,虽然很简单,但答案很长。请耐心等待我...:)(我实际上是在编写说明时在测试站点上执行此操作,以确保我不会错过任何内容...)

我假设您知道如何下载和安装视图模块。确保您还启用了views-ui模块。

  1. 转到站点建设->视图->添加。
  2. 将“recent_posts_by_user”作为视图名称,“recent posts by user”作为描述,“node”作为视图类型。点击下一步。
  3. 在“默认”视图类型下的“字段”块上,点击“+”号。
  4. 在“组”下选择节点,然后检查“节点类型”、“节点标题”和“节点更新日期”字段。点击列表下方的“添加”按钮。
  5. 在基本设置块(左侧)下,单击“显示项目”的“10”,然后更改为“5”或每页所需的项目数,然后单击
  6. “使用寻呼机”下的“更新”,单击“否”和“完整寻呼机”或“迷你寻呼机”,然后再次点击“更新”。
  7. 在样式下,点击“未格式化”并将其更改为“表格”,将所有字段设置为可排序,然后选择“更新日期”作为“默认排序”,然后在“默认排序顺序”上选择“降序”。点击更新。
  8. 点击“保存”以保存迄今为止的进度。

默认视图已完成。耶! 添加块

  1. 现在让我们在“页面”下拉列表中
  2. ,选择“块”并点击“添加显示”。点击“参数”(屏幕中央的块标题)
  3. 点击“覆盖”和“更新”
  4. “参数”右侧的“+”号
  5. 点击“组”下拉列表中 ,选择“用户”并选择“用户身份”。点击“
  6. 如果参数不存在则采取的操作”下的“添加”,选择最后一个选项“提供默认参数”,选择“来自 url 的用户 ID”并选中
  7. “验证器”下的 选择“用户”和“允许数字 UID 和字符串用户名”,
  8. “同时查找节点并使用节点作者” ”,在“参数不验证时采取的操作”下
  9. 选择“隐藏视图/未找到页面 (404)” ,点击“更新”,然后创建“保存”

视图现在让我们确保它显示在正确的页面上。

  1. 转到网站构建 -> 块,搜索“用户最近发布的帖子”块,然后点击“配置”,
  2. 滚动到底部并选择“仅在列出的页面上显示”。并在“页面”文本区域下放入“users/*”,
  3. 点击“保存块”
  4. 现在再次找到“用户最近发布的帖子”块并将其设置为“内容底部”区域(或您的主题可用的任何其他区域) 。
  5. 点击“保存块”

完成!不是火箭科学,而是漫长的过程...drupal 6 视图比 drupal 5 好得多! :)

现在访问用户页面 http://site/users/username 并查看那里显示的表格!

如果您对视图仍有疑问,请联系我。

享受

ok, the answer involves creating a drupal view, so you will need the views module and although simple, the answer is lengthy. please bear with me through this... :) (i am actually doing this on a test site as i write the instructions, to make sure i dont miss anything...)

i assume that you know how to download and install the views module. make sure you also enable the views-ui module.

  1. go to site building->views->add.
  2. put "recent_posts_by_user" for view name, "recent posts by user" for description and "node" for view type. hit next.
  3. under the "default" view type, on the "fields" block, hit the "+" sign.
  4. under "groups" select node, then check the "node type", "node title" and "node updated date" fields. hit the "add" button below the list.
  5. under basic settings block (on the left), click on the "10" for "items for display" and change to "5" or however many items you want per page, and hit "update"
  6. under "use pager", click on "no" and "full pager" or "mini pager" and hit "update" again.
  7. under style, hit "unformatted" and change it to "table" set all fields to sortable, then choose the "updated date" as "default sort", then on "default sort order", select "descending". hit update.
  8. hit "save" to save your progress thus far.

default view is done. YAY! lets add the block

  1. now on the drop-down that says "page", select "block" and hit "add display".
  2. hit "arguments" (block title on the center of the screen)
  3. hit "override" and "update"
  4. hit the "+" sign to the right of "arguments"
  5. on the "groups" drop down, select "user" and select "user id". hit "add"
  6. under "Action to take if argument is not present", select the last option "provide default argument", select "user id from url" and check "Also look for a node and use the node author"
  7. under "validator", select "user" and "Allow both numeric UIDs and string usernames"
  8. under "Action to take if argument does not validate" select "hide view/page not found (404)"
  9. hit "update" then "save"

view is created now lets make sure it shows up on the right pages.

  1. go to site building->blocks, search for the "recent posts by user" block and hit "configure"
  2. scroll all the way to the bottom and select "Show on only the listed pages." and put in "users/*" under the "pages" text area
  3. hit "save block"
  4. now find the "recent posts by user" block again and set it to "content bottom" region (or any other region your theme has available).
  5. hit "save blocks"

DONE! Not rocket-science, but lengthy process... drupal 6 views is so much better than drupal 5! :)

now go visit a user page http://site/users/username and see the table show up there!

hit me up if you still have questions about views.

enjoy

黑白记忆 2024-09-03 08:56:50

放入使用 URL 参数中的用户 ID 的视图参数。它将是 arg(1)。这应该会过滤由您正在查看的个人资料创作的内容。这适用于块或内容窗格。

Put in a Views Argument that uses the User ID from the URL argument. It will be arg(1). That should filter content that was authored by the profile you are looking at. That can work for a block or content pane.

凡尘雨 2024-09-03 08:56:50

我只是更喜欢你去查看 ->对条件进行排序并添加节点:更新日期并将其标记为降序,因为它显示了一段时间内的粒度。

此外,您不仅可以获取表格样式的最新节点,还可以获取所有节点的最新节点。

I just prefer you to go to Views -> Sort Criteria and add the Node:Updated Date and mark it as descending as it shows the granularity over the time.

Moreover, you can also get the most recent node not only to the table style but to all.

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