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

时间:2019-06-01 19:29:18

标签: php laravel octobercms

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

1 个答案:

答案 0 :(得分:0)

假设我们正在生成链接:public static String readTestData(String key) throws IllegalArgumentException, IOException { String path = System.getProperty("user.dir") + "/data/testData.xlsx"; FileInputStream fs = new FileInputStream(path); Workbook SapWorkbook = new XSSFWorkbook(fs); Sheet SapSheet = SapWorkbook.getSheet("Sheet1"); int rowCount = SapSheet.getLastRowNum() - SapSheet.getFirstRowNum(); for (int i = 0; i < rowCount + 1; i++) { Row row = SapSheet.getRow(i); if (key.equals(row.getCell(0).getStringCellValue())) { return row.getCell(1).getStringCellValue(); } } throw new IllegalArgumentException(String.format("%s not found!", key)); }

所以id将为www.example.com/profile/joe,现在我们需要找到该用户的记录并使用它

  

在代码中找到它

joe
  

在模板中使用

[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();
} 
?> 
== 

如有任何疑问,请添加评论。

相关问题