I Have problem with calling login form into a page.

I build a .phtml file called members.phtml & login.phtml locate on base/default/template/members


    <?php if(Mage::getSingleton('customer/session')->isLoggedIn()): ?>
    <?php $loadHtml = 'Hi Logged User...welcome'; ?>
        <?php echo $loadHtml; ?>
    <?php else: ?>
    <?php $loadHtml = 'Please register or login if already registered.'; ?>

        <?php echo $loadHtml; ?>
        <?php echo this->getLayout()->createBlock('members/login')->setTemplate('members/login.phtml')->toHtml();  // show login form ?>
    <?php endif; ?>

login.phtml I copied from standard customer/account login folder

Then I create CMS -> Page -> Members

the content of that page is

{{block type="core/template" name="membersState" template="members/members.phtml"}}

The problem is :

The login block doesn't show when guest user accessing the Member Page, does the code that I used is wrong..


welcome to Magento Stack Exchange. Don't worry, English is not at all a problem here as long as we understand what your real question is. :)

Your CMS page content looks good. But your members.phtml file has a small problem. Problem resides exactly here :

<?php echo this->getLayout()->createBlock('members/login')->setTemplate('members/login.phtml')->toHtml();  // show login form ?>

Problems are given below:

  1. You are using this. It is wrong. It should be $this.

  2. You are trying to create a block of type customer/login which Magento is unaware of. You really need to use a block type which Magento knows. In this particular context, the block type is customer/form_login. So your code will look like this.

    <?php echo $this->getLayout()->createBlock('customer/form_login')->setTemplate('members/login.phtml')->toHtml();  // show login form ?>

I believe this will resolve your problem. Good luck

  • wow.. thank you so much @rajeev-k-tomy for the explanation, yes it's indeed resolved my problem. all above answer is also resolved my problem, but I don't wanna call mini.login.form. – MarzuQ Jan 25 '16 at 13:53

Try below code to call mini.login.phtml

    echo $this->getLayout()->createBlock('customer/form_login')->setTemplate('customer/form/mini.login.phtml')->toHtml(); ?>

You have done some mistake on code.

If you have using magento default login form then you need to change

You should change Block type members/login to customer/form_login.Also You need to change template file to customer/form/mini.login.phtml from members/login.phtml.

Also as per as ,my concept base/default/template/members folder does not exit in default magento.You may be use 3rd party extension or have done some customization

If Your template have feature then you may be miss form key at that form.See details at What is getBlockHtml('formkey')?

  • thank-you for the answer @amit-bera but it's not what I looking for – MarzuQ Jan 25 '16 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.