其他用户如何在octobercms中查看用户的个人资料详情?

How can other users view a user's profile details in octobercms?

使用 url 中的用户 ID 或名称作为参数,并使用 {{ user.name }}{{ user.phone }} 等显示特定详细信息,向用户显示用户信息非常简单。但是我如何向其他用户显示特定的用户信息。当我单击 www.example.com/profile/joe 时,它会将我带到 joe 的个人资料。尝试注销或使用其他帐户会引发错误。

这是我目前所做的。我的个人资料 url 有

 url = "/:id"

和我的php块

 [session]
 ==
 <?php function onStart(){
$profile = $this->param('id');  
} 
?> 
== 

这链接到个人资料页面

<a href="{{ 'profile'|page ({ id: user.name }) }}"><button style="font-family: arial" class="btn btn-sm btn-light rounded--lg-pill shadow rounded border col-6">View Profile</button></a> 

使用{{ user.name }}{{ user.phone }}等显示所有登录用户的信息。我只是迷失在这里如何让其他用户可以使用一个用户的配置文件。

编辑: 如果我使用 $userProfile = Auth::findUserById($profile)

目前正在工作

连接到 <a href = ''{{ id: users.id }}''>View Profile></a>

如果我把它改成它仍然有效 $userProfile = Auth::findUserByLogin($profile) 连接到 <a href = ''{{ id: users.username }}''>View Profile></a> 要么 <a href = ''{{ id: users.email }}''>View Profile></a>

但我会喜欢它使用不同的领域工作

<a href = ''{{ id: user.company_name }}''>View Profile></a> 而不是 ID 或登录详细信息

假设我们正在生成 link : www.example.com/profile/joe

所以 id 将是 joe 现在我们需要找到该用户的记录并使用它

to find it in code

[session]
==
<?php function onStart(){
     $profile = $this->param('id');  
     $this['userProfile'] = Auth::findUserByLogin($profile);
     // you can use other field if you need 
     // $this['userProfile'] = \RainLab\User\Models\User::where('username', $profile)->first();
} 
?> 
== 

use it in template

{{ userProfile.name }}, {{ userProfile.phone }}

如有疑问请补充。