Mini Login Form in Magento Home Page

1. Find and modify cms_index_index tag within /layout/cms.xml :
[codesyntax lang="xml" lines="no" container="pre" tab_width="4"] <cms_index_index translate="label"> <label>CMS Home Page</label> <reference name="head"> <action method="setForcedTitle"><title>Homepage登录框</title></action> </reference> <reference name="content"> <block type="customer/form_login" name="customer_form_mini_login" after="-" template="customer/form/mini.login.phtml" /> </reference> </cms_index_index> [/codesyntax]
2. Hide the form within /template/customer/form/mini.login.phtml if the customer is logged in :
[codesyntax lang="php" lines="no" container="pre" tab_width="4"]
<?php if (!Mage::getSingleton( 'customer/session' )->isLoggedIn()):?>
<div class="block block-login">
    ......
</div>
<?php endif ?>
[/codesyntax]
3. Modify the page header within /template/page/html/head.phtml :
[codesyntax lang="php" lines="no" container="pre" tab_width="4"]
<title>
<?php
if (Mage::getSingleton('cms/page')->getTitle() == 'Home') {
    echo $this->getDefaultTitle();
} elseif ($this->getForcedTitle()) {
    echo Mage::getStoreConfig('design/head/title_prefix') . ' '
       . $this->getForcedTitle() . ' '
       . Mage::getStoreConfig('design/head/title_suffix');
} else {
    echo $this->getTitle();
}
?>
</title>
[/codesyntax]
4. Create the cms page in backend and set it as home page, then you can see the login form.
Posted in Magento| Tagged |
  1. 又发现了一个学MAgento的地方。。。。

  2. 呵呵,目前还是业余水平