【问题标题】:Explain URL routing in PHPFox解释 PHPFox 中的 URL 路由
【发布时间】:2015-03-26 00:24:15
【问题描述】:

我正在为我的网站使用 PHPFox。假设我想查看用户 ID 为 126 的用户的个人资料。每当我点击任何用户名时,地址栏中都会出现以下 URL http://34.144.60.142/profile-126/(如果是 user_id 126。对于其他用户,可能会出现一些其他数字,例如 profile-244对于 user_id 为 244 的用户)。

从上面的 URL 中,我完全不知道如何处理配置文件请求和获取配置文件数据。

谁能详细解释一下PHPFox中路由是如何完成的。

谢谢。

【问题讨论】:

    标签: php url routing url-routing phpfox


    【解决方案1】:
    actually when we didn't allow user name in registration then phpfox automatically set a user name "profile-user_id" for eg : if any user have user_id 126 then it's username must be "profile-126" and it's unique.
    
    when you visit any user profile page like 
    
    http://34.144.60.142/profile-126/
    
    http://34.144.60.142/profile-244/
    
    so phpfox fetch data from that username and particular profile will display.
    

    【讨论】:

    • 这件事我已经知道了,但我的问题是如何使用哪些类和方法获取配置文件数据?如果你能专注于这件事,那就太好了。
    • $aRow = Phpfox::getService('user')->get($mUser, false);
    • 感谢您的大力帮助。但我只有一个查询。它是否适用于已登录和未登录的用户。我的意思是登录后我可以看到其他人的个人资料吗?还有一件事我怎样才能获得有关其他用户与登录用户关系的数据?
    • 你可以在函数中传递特定用户的user_id或用户名
    • 不,你没有明白我的意思。我想获取登录用户与所有其他用户的关系状态。我应该怎么得到这个?
    【解决方案2】:
    on profile.index controller
    
    system get user name by using this syntax
    
    $mUser = $this->request()->get('req1');
    
    now system fetch user data from user name by using predefine function.
    
    $aRow = Phpfox::getService('user')->get($mUser, false);
    
    this function exists in module/user/include/service/user.class.php service class.
    

    【讨论】:

    • 感谢您的回答。但我想要的远不止这些。我想要特定用户的数据自定义数据。如何得到它?您能否按照上面提到的获取用户配置文件的方式简单解释一下?这对我有很大的帮助。
    • 你可以从这个函数中获取所有自定义数据 $aCustomFields= Phpfox::getService('custom')->getForEdit(array('user_main', 'user_panel', 'profile_panel'), $iUserId , $iUserGroupId, false, Phpfox::getUserId());
    • 感谢您的大力帮助。但我只有一个查询。它是否适用于已登录和未登录的用户。我的意思是登录后我可以看到其他人的个人资料吗?还有一件事我怎样才能获得有关其他用户与登录用户关系的数据?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-26
    • 1970-01-01
    • 2017-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多