Magento添加一个下拉登陆菜单Create Magento Dropdown Login in a few minutes

Dropdown login forms are not a feature many online stores use, but in some cases they could be quite useful UX feature. In this tutorial, I will explain how to create such a dropdown in a few minutes!
并不是每一个站都用下拉登陆菜单,但对某些时候确实非常实用。这次我们就来体验一下如何给Magento制作一个下拉登陆菜单。
Let’s open app/design/frontend/base/default/layout/customer.xml and just add the line that’s highlighted.
打开上述文件app/design/frontend/base/default/layout/customer.xml ,添加高两部分代码。
<customer_logged_out>
<!---<reference name="right">
<block type="customer/form_login" name="customer_form_mini_login" before="-" template="customer/form/mini.login.phtml"/>
</reference>-->
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
<block type="core/template" name="customer_form_mini_login" before="-" template="customer/form/mini.login.phtml"/>
</reference>
<remove name="reorder"></remove>
</customer_logged_out>
Open app/design/frontend/base/default/template/customer/form/mini.login.phtml as well and place the code below instead.
打开 app/design/frontend/base/default/template/customer/form/mini.login.phtml ,用下面代码替代。
<style>
#dropdown
{
position: absolute;
top: 70px;
right: 20px;
visibility: hidden;
float:right;
}
.last:hover #dropdown
{
visibility: visible;
}
</style>
<div class="block block-login" id="dropdown">
<div class="block-title">
<strong><span><?php echo $this->__('Login') ?></span></strong>
</div>
<form action="<?php echo $this->getUrl('customer/account/loginPost') ?>" method="post">
<?php echo $this->getBlockHtml('formkey'); ?>
<div class="block-content">
<label for="mini-login"><?php echo $this->__('Email:') ?></label><input type="text" name="login[username]" id="mini-login" class="input-text" />
<label for="mini-password"><?php echo $this->__('Password:') ?></label><input type="password" name="login[password]" id="mini-password" class="input-text" />
<div class="actions">
<button type="submit" class="button"><span><span><?php echo $this->__('Login') ?></span></span></button>
</div>
</div>
</form>
</div>
And that’s it! Your login form should appear when hovering over ‘Log In‘ link in the top menu:
Ok,现在去看看你的登录框吧,鼠标滑过Login,就出现了。

The important thing to note here is that we’re using Magento’s default mini.login.phtml with slight modifications for it to work on homepage.
We’re also using core/template block instead of customer/form_login. The reason for this is that the latter sets the page title to ‘Customer login‘ on all pages it’s being displayed on.
As a downside to using different block, we now can’t use methods of the customer/form_login block. That is why we’re using $this->getUrl(‘customer/account/loginPost’) as a form action instead of $this->getPostActionUrl().
It’s also important that you have a form key present, otherwise your form won’t get processed.
<?php echo $this->getBlockHtml('formkey'); ?>
And all that’s left is to have your frontend developer (you?) make the dropdown pretty
Magento添加一个下拉登陆菜单Create Magento Dropdown Login in a few minutes的更多相关文章
- 在Ueditor的内容区添加一个下拉选框改变事件
<script>html='';html=html+` <select name="" onchange='this.appendChild(document.g ...
- 为下拉式菜单(DropDownList)添加第一个选项
很多方法可以为为下拉式菜单(DropDownList)添加第一个选项,下面是Insus.NET小结了几个方法,仅供参考: Html code: <body> <form id= ...
- 何使用CSS写出一个下拉菜单。
导航菜单是每个网站所必备的功能,也是每个学习制作网站的朋友所必须接触的,如何用css样式制作一个简单漂亮的二级下拉菜单呢? 下面为大家分享一下我的经验 方法步骤: 第一步 : 首页我们打开Subli ...
- 原生Js_实现简单的下拉折叠菜单(添加弹出动画效果)
用javascript实现简单的下拉折叠菜单效果 实现步骤 (a)获得各操作的dom对象: (b)在所有菜单按钮对象上添加单击事件: (c)设置所有菜单按钮样式为空,并将当前按钮的样式设置为“acti ...
- iOS开发笔记13:顶部标签式导航栏及下拉分类菜单
当内容及分类较多时,往往采用顶部标签式导航栏,例如网易新闻客户端的顶部分类导航,最近刚好有这样的应用场景,参考网络上一些demo,实现了这种导航效果,记录一些要点. 效果图(由于视频转GIF掉帧,滑动 ...
- MDNavBarView下拉导航菜单(仿美团导航下拉菜单)
说到下拉导航菜单这个东西用得还真不少,细心算一下做开发以来这样的菜单已经写了第三次了,但基本都是不能复用.感觉特累人.不经意看到同事写一个类似的下拉菜单,但他引用了开源库仿大众菜单的库,大致看了一下, ...
- Jquery垂直下拉二级菜单
自己做了一个基于Jquery 的垂直下拉二级菜单功能,直接看图: Html的代码如下: <!DOCTYPE html> <html> <head> <meta ...
- 一款jQuery立体感动态下拉导航菜单特效
一款jQuery立体感动态下拉导航菜单特效,鼠标经过,在菜单栏上方下拉出一个背景图片,效果十分不错的一款jquery特效. 对IE6都是兼容的,希望大家好好研究研究. 适用浏览器:IE6.IE7.IE ...
- html基础——下拉式菜单
一个网站能否让用户容易使用该网站往往是由菜单栏体现出来,因为它为网页的大多数页面提供功能入口.一个轻轻的点击以后,即可显示出菜单项,将网站的大部分页面和功能显示出来让用户清楚了解从而用户节约一定的时间 ...
随机推荐
- jQuery回调、递延对象总结(一)jQuery.Callbacks详解
前言: 作为参数传递给另一个函数执行的函数我们称为回调函数,那么该回调又是否是异步的呢,何谓异步,如:作为事件处理器,或作为参数传递给 (setTimeout,setInterval)这样的异步函数, ...
- TYVJ P1015 公路乘车 &&洛谷 P1192 台阶问题 Label:dp
题目描述 有N级的台阶,你一开始在底部,每次可以向上迈最多K级台阶(最少1级),问到达第N级台阶有多少种不同方式. 输入输出格式 输入格式: 输入文件的仅包含两个正整数N,K. 输出格式: 输入文件s ...
- Log4j日志级别
日志记录器(Logger)是日志处理的核心组件.log4j具有5种正常级别(Level). 日志记录器(Logger)的可用级别Level (不包括自定义级别 Level), 以下内容就是摘自log4 ...
- ERROR 2013 (HY000): Lost connection to MySQL server at 'waiting for initial communication packet', system error: 2
ERROR (HY000): Lost connection to MySQL server at 'waiting for initial communication packet', system ...
- [转].net自定义验证控件CustomValidator的使用
本文转自:http://tech.cncms.com/web/aspnet/96310.html CustomValidator验证控件,可以自定义验证函数,实现其它几个验证控件不能实现的验证规则,最 ...
- redmine问题
问题1: 404 版本库中不存在该条目和(或)其修订版本. 1.1 GIT库: 参考:http://stackoverflow.com/questions/13000247/redmine-gitol ...
- Laravel Eloquent 判断取出的结果集是否为空
在使用Laravel Eloquent模型时,我们可能要判断取出的结果集是否为空,但我们发现直接使用is_null或empty是无法判段它结果集是否为空的. var_dump之后我们很容易发现,即使取 ...
- 不再以讹传讹,GET和POST的真正区别
不再以讹传讹,GET和POST的真正区别 网上的多数答案都是错的 在 2012年05月03日 那天写的 已经有 19940 次阅读了 感谢 参考或原文 www.cnblogs.com 服务 ...
- Oracle 数据库安装
下载 www.oracle.com ->Downloads -> Oracle Database 安装: 解压到同一文件夹下 仅安装数据库软件 单实例数据库安装 企业版 oracle基目录 ...
- oracle 多表查询
1.注意点 在查询过程中,不确定数据库表中的数据量,先查询数据量,数据量较大,则不能直接查询(select * from emp),如果数据量较大,直接查询容易造成死机或者数据读取较慢,如果较小可以查 ...