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的更多相关文章

  1. 在Ueditor的内容区添加一个下拉选框改变事件

    <script>html='';html=html+` <select name="" onchange='this.appendChild(document.g ...

  2. 为下拉式菜单(DropDownList)添加第一个选项

    很多方法可以为为下拉式菜单(DropDownList)添加第一个选项,下面是Insus.NET小结了几个方法,仅供参考: Html code: <body>    <form id= ...

  3. 何使用CSS写出一个下拉菜单。

    导航菜单是每个网站所必备的功能,也是每个学习制作网站的朋友所必须接触的,如何用css样式制作一个简单漂亮的二级下拉菜单呢? 下面为大家分享一下我的经验 方法步骤: 第一步  : 首页我们打开Subli ...

  4. 原生Js_实现简单的下拉折叠菜单(添加弹出动画效果)

    用javascript实现简单的下拉折叠菜单效果 实现步骤 (a)获得各操作的dom对象: (b)在所有菜单按钮对象上添加单击事件: (c)设置所有菜单按钮样式为空,并将当前按钮的样式设置为“acti ...

  5. iOS开发笔记13:顶部标签式导航栏及下拉分类菜单

    当内容及分类较多时,往往采用顶部标签式导航栏,例如网易新闻客户端的顶部分类导航,最近刚好有这样的应用场景,参考网络上一些demo,实现了这种导航效果,记录一些要点. 效果图(由于视频转GIF掉帧,滑动 ...

  6. MDNavBarView下拉导航菜单(仿美团导航下拉菜单)

    说到下拉导航菜单这个东西用得还真不少,细心算一下做开发以来这样的菜单已经写了第三次了,但基本都是不能复用.感觉特累人.不经意看到同事写一个类似的下拉菜单,但他引用了开源库仿大众菜单的库,大致看了一下, ...

  7. Jquery垂直下拉二级菜单

    自己做了一个基于Jquery 的垂直下拉二级菜单功能,直接看图: Html的代码如下: <!DOCTYPE html> <html> <head> <meta ...

  8. 一款jQuery立体感动态下拉导航菜单特效

    一款jQuery立体感动态下拉导航菜单特效,鼠标经过,在菜单栏上方下拉出一个背景图片,效果十分不错的一款jquery特效. 对IE6都是兼容的,希望大家好好研究研究. 适用浏览器:IE6.IE7.IE ...

  9. html基础——下拉式菜单

    一个网站能否让用户容易使用该网站往往是由菜单栏体现出来,因为它为网页的大多数页面提供功能入口.一个轻轻的点击以后,即可显示出菜单项,将网站的大部分页面和功能显示出来让用户清楚了解从而用户节约一定的时间 ...

随机推荐

  1. Travelling

    Travelling Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. BZOJ3075 : [Usaco2013]Necklace

    首先对b串做kmp求出nxt数组. 设f[i][j]表示考虑了a的前i个字符,在b中匹配到了j的最长长度,按照kmp算法直接转移即可. $ans=n-\max(f[n][j])$. 时间复杂度$O(n ...

  3. BZOJ 1121 & science

    1121: [POI2008]激光发射器SZK Time Limit: 10 Sec Memory Limit: 162 MB Submit: 647 Solved: 537 [Submit][Sta ...

  4. 【BZOJ】1854: [Scoi2010]游戏

    http://www.lydsy.com/JudgeOnline/problem.php?id=1854 题意:n个数据,每个数据有两个属性,要求取一些数据且每个数据取一个属性使得组成连续的一段单调递 ...

  5. Java/Js下使用正则表达式匹配嵌套Html标签

    转自:http://www.jb51.net/article/24422.htm 以前写过一篇文章讲解如何使用正则表达式完美解决Html嵌套标签的匹配问题(使用正则表达式匹配嵌套Html标签),但是里 ...

  6. kvm快照

    Kvm快照: 1.基于lvm的快照 2.kvm自带的快照功能(需要qcow2 磁盘文件才支持快照) 关闭kvm虚拟机: 查看磁盘文件信息: [root@super67 ~]# qemu-img inf ...

  7. C# 取整

    double a = 1.1478; Math.Celling(a): 向上取整,结果为2 Math.Float(a); 向下取整,结果为1 Math.Round(a,2);  保留两位小数的奇进偶舍 ...

  8. 【液晶模块系列基础视频】4.1.X-GUI图形界面库-画线画圆等函数简介

    [液晶模块系列基础视频]4.1.X-GUI图形界面库-画线画圆等函数简介 ============================== 技术论坛:http://www.eeschool.org 博客地 ...

  9. discuz二次开发之后导航无法高亮 $mnid == $nav[navid]解决办法(转)

    在 <body>前面加入如下代码:body原来就有一个class,直接在增加一个进行测试 <!--{eval $mnid = getcurrentnav()}--> <! ...

  10. Mybatis resultMap空值映射问题解决

    Mybatis在使用resultMap来映射查询结果中的列,如果查询结果中包含空值的列(不是null),则Mybatis在映射的时候,不会映射这个字段,例如 查询 name,sex,age,数据库中的 ...