- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用内容配置文件模块。当用户在他们的查看个人资料页面上并按编辑时,他们希望显示个人资料编辑页面,而不是现在的帐户设置。内容配置文件编辑页面的路径是“user/%/edit/uprofile”。有谁知道如何将“user/%/edit/uprofile”设置为“user/%/edit”的默认选项卡?
最佳答案
此示例适用于内容配置文件选项卡。只需更改 $type
到配置文件的内容类型的简称。这也展示了如何清理代码以供实际使用(我之前的示例非常非常冗长):
function mymodule_menu_alter(&$items) {
// Specify the content profile type you'd like to work with
$type = 'profile';
// Make sure the user has a Content Profile to edit
if (!empty($items['user/%user_category/edit/' . $type])) {
// Pull out the menu items we want to modify.
$account = &$items['user/%user_category/edit/account'];
$edit = &$items['user/%user_category/edit'];
$profile = &$items['user/%user_category/edit/' . $type];
// Specify the Edit Account page as just a regular tab.
// You do not need to change this block: this will always be the same as long
// as you don't want Edit account to be the default tab.
$account = array(
'type' => MENU_LOCAL_TASK,
'page callback' => $edit['page callback'],
'page arguments' => $edit['page arguments'],
'access callback' => $edit['access callback'],
'access arguments' => $edit['access arguments'],
'module' => $edit['module'],
'file' => $edit['file'],
) + $account;
// Change the default action to take when hitting user/<UID>/edit to
// the content profile
$edit = array(
'page callback' => $profile['page callback'],
'page arguments' => $profile['page arguments'],
'access callback' => $profile['access callback'],
'access arguments' => $profile['access arguments'],
'file' => $profile['file'],
'file path' => $profile['file path'],
) + $edit;
// Specify the profile page as the default tab and remove settings
// already set above
$profile['type'] = MENU_DEFAULT_LOCAL_TASK;
unset($profile['page callback'],
$profile['page arguments'],
$profile['access callback'],
$profile['access arguments'],
$profile['file'],
$profile['file path']);
}
}
我没有意识到您想要更改编辑 下的默认选项卡。它与我在下面描述的一般原则相同,但有一些小的修改。此示例将使个人 选项卡(位于 user/<UID>/edit/Personal
)成为默认选项卡,而不是帐户选项卡:
function mymodule_menu_alter(&$items) {
// Specify the Edit Account page as just a regular tab.
// You do not need to change this block: this will always be the same as long
// as you don't want Edit account to be the default tab.
$items['user/%user_category/edit/account']['type'] = MENU_LOCAL_TASK;
$items['user/%user_category/edit/account']['page callback'] = $items['user/%user_category/edit']['page callback'];
$items['user/%user_category/edit/account']['page arguments'] = $items['user/%user_category/edit']['page arguments'];
$items['user/%user_category/edit/account']['access callback'] = $items['user/%user_category/edit']['access callback'];
$items['user/%user_category/edit/account']['access arguments'] = $items['user/%user_category/edit']['access arguments'];
$items['user/%user_category/edit/account']['module'] = $items['user/%user_category/edit']['module'];
$items['user/%user_category/edit/account']['file'] = $items['user/%user_category/edit']['file'];
// Change default action to take when hitting user/<UID>/edit to
// the settings of the page you want to use.
// -- Custom settings start here --
$items['user/%user_category/edit']['page callback'] = $items['user/%user_category/edit/Personal']['page callback'];
$items['user/%user_category/edit']['page arguments'] = $items['user/%user_category/edit/Personal']['page arguments'];
$items['user/%user_category/edit']['access callback'] = $items['user/%user_category/edit/Personal']['access callback'];
$items['user/%user_category/edit']['access arguments'] = $items['user/%user_category/edit/Personal']['access arguments'];
$items['user/%user_category/edit']['module'] = $items['user/%user_category/edit/Personal']['module'];
$items['user/%user_category/edit']['file'] = $items['user/%user_category/edit/Personal']['file'];
// When loading a profile tab, user_edit needs two parameters. The second parameter is the name of the profile
// (i.e. Personal from user/<UID>/edit/Personal).
$items['user/%user_category/edit']['page arguments'] = array(1, 'Personal');
// Specify the Personal page as the default tab and remove settings
// already set above */
$items['user/%user_category/edit/Personal']['type'] = MENU_DEFAULT_LOCAL_TASK;
unset($items['user/%user_category/edit/Personal']['page callback']);
unset($items['user/%user_category/edit/Personal']['page arguments']);
unset($items['user/%user_category/edit/Personal']['access callback']);
unset($items['user/%user_category/edit/Personal']['access arguments']);
unset($items['user/%user_category/edit/Personal']['module']);
unset($items['user/%user_category/edit/Personal']['file']);
}
您可以使用 hook_menu_alter
执行此操作并更改特定选项卡的类型。
更改默认选项卡是一个有点痛苦的过程。基本上,默认选项卡会继承页面的所有属性,而无需选择任何选项卡。这允许用户转到 user/UID
并获取查看页面,而无需直接转到 user/UID/view
.
要更清楚地了解这一点,请查看 user_menu()
Hook 实现。注意如何 $items['user/%user/view']
很空,$items['user/%user_uid_optional']
包含您希望在 $items['user/%user/view']
下看到的所有设置.
因此,您首先要将 View 选项卡设置为常规选项卡:为此,您必须复制附加到 user/UID
的所有设置。菜单项并将它们放入 user/UID/view
菜单项。
完成后,您将替换 user/UID
的设置使用要成为默认选项卡的选项卡的设置。
最后,您要取消默认选项卡的所有菜单项设置,因为它将继承 user/UID
的设置。 .
查看此代码,它使 Edit 选项卡成为默认选项卡:
function mymodule_menu_alter(&$items) {
// Specify the View page as just a regular tab.
// You do not need to change this block: this will always be the same as long
// as you don't want View to be the default tab.
$items['user/%user/view']['type'] = MENU_LOCAL_TASK;
$items['user/%user/view']['page callback'] = $items['user/%user_uid_optional']['page callback'];
$items['user/%user/view']['page arguments'] = $items['user/%user_uid_optional']['page arguments'];
$items['user/%user/view']['access callback'] = $items['user/%user_uid_optional']['access callback'];
$items['user/%user/view']['access arguments'] = $items['user/%user_uid_optional']['access arguments'];
$items['user/%user/view']['file'] = $items['user/%user_uid_optional']['file'];
// Normal tabs don't have a weight
unset($items['user/%user/view']['weight']);
// Change default action to take when hitting user/<UID> to
// the settings of the page you want to use.
// -- Custom settings start here --
$items['user/%user_uid_optional']['page callback'] = $items['user/%user_category/edit']['page callback'];
$items['user/%user_uid_optional']['page arguments'] = $items['user/%user_category/edit']['page arguments'];
$items['user/%user_uid_optional']['access callback'] = $items['user/%user_category/edit']['access callback'];
$items['user/%user_uid_optional']['access arguments'] = $items['user/%user_category/edit']['access arguments'];
$items['user/%user_uid_optional']['file'] = $items['user/%user_category/edit']['file'];
// Specify the Edit page as the default tab and remove settings
// already set above
$items['user/%user_category/edit']['type'] = MENU_DEFAULT_LOCAL_TASK;
$items['user/%user_category/edit']['weight'] = -10;
unset($items['user/%user_category/edit']['page callback']);
unset($items['user/%user_category/edit']['page arguments']);
unset($items['user/%user_category/edit']['access callback']);
unset($items['user/%user_category/edit']['access arguments']);
unset($items['user/%user_category/edit']['file']);
}
用您的菜单项的设置替换函数的第二部分,您应该处于良好状态。当然,记得在进行任何菜单更改后清除缓存以使它们生效。
关于Drupal - 将 'user/%/edit/uprofile' 设置为 'user/%/edit' 上的默认选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3408602/
export class UserListComponent implements OnInit{ users; constructor(private userService: UserS
我最近在我的系统中遇到了 Java 语言环境的问题,我试图用这个配置运行一个项目: -Duser.language=pt_BR -Duser.country=BR 谷歌搜索后,我找到了this sit
1 当我希望出现注册错误时,我的代码出现问题:管理器不可用; 'auth.User' 已替换为 'users.User' ,我尝试解决其他问题,与 Manager 不可用相同; 'auth.User'
Loopback 非常酷,但这是我迄今为止遇到的一个缺点,我真的不确定如何解决它。内置用户模型在我的 MongoDB 数据库中生成一个名为“User”的集合,当我尝试根据 Loopback.js 自己
我在 aws cognito 中有以下用户组。行政成员付费成员(member) 我想在所有用户注册我的应用程序时将所有用户默认分配到 Member 用户组,这样我就可以为该用户组分配不同的 IAM A
blogsIndex.blade.php @extends('layouts.default') @section('details')
我正在尝试在Rails 3开发环境中使用sqlite3而不是MySQL,但是遇到了问题。尝试执行rake db:migrate时,我得到: SQLite3::SQLException: no such
尝试使用 构建 API Phoenix v1.3 按照本教程: https://dreamconception.com/tech/phoenix-full-fledged-api-in-five-mi
我正在使用通过模板 cookie-cutter 创建的 Django。当我尝试在本地使用 docker 运行项目时,出现以下错误。 FATAL: password authentication fai
我正在尝试使用 node.js/adonis 创建新用户 我创建了这两个函数: const User = use("App/Models/User") async store ({ request,
我想安排一些事情,例如 GET 请求 http://example.com/user/foo@bar.com 内部调用脚本 /var/www/example.com/rest/user/GET.php
我是一名具有可用性工程背景的软件开发人员。当我在研究生院学习可用性工程时,其中一位教授有一句口头禅:“你不是用户”。我们的想法是,我们需要将 UI 设计基于实际的用户研究,而不是我们自己关于 UI 应
您好,我正在制作一个使用互联网发送消息的消息传递应用程序。我需要从用户 a 向用户 b 发出通知。 我使用这段代码: if (toUser!= nil){ parseMessage[@
在 ruby/ror 中你可以这样做: user = User.new(params[:user]) 它使用发布表单中的值填充新对象。 使用 django/python 可以完成类似的事情吗? 最
每当我编辑用户的角色时,用户都需要注销并重新登录以查看更改。提升用户时没有问题,因为他们在再次登录之前不会看到额外的权限。但是,当降级发生时,用户仍将保留其现有角色,这会带来安全风险。想象一下,撤销一
我的核心数据有线问题。使用 iOS 10 中的 Swift3,每次使用 获取或存储数据时,我都会获得托管对象上下文 func getContext () -> NSManagedObjectCont
我发现当我使用 users_path(user) 时它返回 /users.id 其中 id 是用户的 ID 但我希望它返回 /用户/ID。我的配置 routes.rb 如下所示。 # config/r
我的应用程序在我的测试设备上正常运行(当我通过 ADT 安装它时,当我通过导出的 APK 文件安装它时)但它在 Play Store 测试设备上失败并出现以下错误: Permission Denial
创建模型的第一个条目会抛出错误 我执行了以下命令进行迁移 manage.py makemigrations manage.py migrate 在我执行这些命令以在数据库中创建第一个“数据”之后,一切
我正在尝试实现一个 getter,但它在下面代码 fragment 的最后一行向我显示了这个错误。 代码是—— class AuthRepository extends BaseAuthReposit
我是一名优秀的程序员,十分优秀!