首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在osclass中,将http://domainname/user/profile/1改为http://domainname/username,是可能的吗?

问在osclass中,将http://domainname/user/profile/1改为http://domainname/username,是可能的吗?
EN

Stack Overflow用户
提问于 2015-05-14 20:50:18
回答 2查看 1.1K关注 0票数 0

您好,我正在使用osclass,要查看任何用户配置文件,我必须转到这个启用了固定链接的url

http://domainname/user/profile/1

是否可以使用此url查看用户配置文件

http://domainname/username

使用简单的固定链接更改?或者我必须为此更改代码?

请告诉我怎么做。

EN

回答 2

Stack Overflow用户

发布于 2015-05-15 05:19:57

首先,对于id为42的用户,您可以让该用户选择用户名(这是Osclass中的一个功能),这样这两个URL将指向同一个页面:

  • http://domain.com/user/profile/42
  • http://domain.com/user/profile/myowncustomusername

现在关于更改“用户/配置文件”,您需要转到管理员Settings > Permalinks,在那里您可以更改用于路由/重写URL的规则。

不过,有两个问题:

像http://domain.com/something这样的

  1. URL用于搜索和分类(对所有分类都有一个很好的URL)。此修改将导致behavior.
  2. Osclass不允许您在管理中保存空的重写规则。

我可以让你开始,但我认为尝试改变它可能会奏效,但需要大量的测试和令人头疼的事情。如果你问我,这是不值得的麻烦。

用于处理第一个问题的,

在查找名为something的类别之前,您需要修改搜索控制器以首先查找用户名为something的用户。

在/oc-includes/osclass/controller/search.php中看一下第78行。

用于处理第二个问题的,

你可以修改if-block:

代码语言:javascript
复制
if(!osc_validate_text($rewrite_user_profile)) {
   $errors += 1;
} else {
   osc_set_preference('rewrite_user_profile', $rewrite_user_profile);
}

出自:

代码语言:javascript
复制
osc_set_preference('rewrite_user_profile', $rewrite_user_profile);

在文件/oc-admin/controller/settings/permalinks.php中的第245行附近。

票数 0
EN

Stack Overflow用户

发布于 2017-09-29 19:35:03

有一种方法可以使用phpmyadmin更改此url。

转到phpmyadmin,在相关数据库中找到表名oc-t-preference。在那里你可以找到名为'rewrite_user_profile‘的字段,默认值是'user/profile’。您可以将其更改为所需的内容,如“shop”或保留为空。这很好,你的期望已经准备好了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30237861

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档