Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Help! Problem with layout and blocks
 
cooldar
Sr. Member
 
Total Posts:  95
Joined:  2008-05-14
 

Hi Magento Gurus,

I am trying to build a module but for some reason it is not rendering the correct layout. I kept on getting the error “ fatal error : Call to a member function getIsAnonymous() on a non-object in /home/rchengpc/magento/app/code/core/Mage/Core/Block/Abstract.php on line 552”

In my Profile controller I have

public function indexAction()
    
{
        
echo "test";

        
$this->loadLayout();

        
$this->getLayout()->getBlock('content')->append(
            
$this->getLayout()->createBlock('mymodule/profile')    <------- this line would cause fatal error Call to a member  function  getIsAnonymous() on a non-object in /home/rchengpc/magento/app/code/core/Mage/Core/Block/Abstract.php on line 552
        
);

        
$this->getLayout()->getBlock('head')->setTitle($this->__('My Profile'));
        
$this->renderLayout();
    
}

In mymodule.xml (in the layout folder) I have

<mymodule_profile_index>
        <!-- 
Mage_Customer -->
        <
reference name="root">
            <
action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        </
reference>
        <
reference name="content">
            <
block type="mymodule/profile" name="mymodule_profile" template="customer/account/dashboard.phtml">
                <
block type="customer/account_dashboard_hello" name="customer_account_dashboard_hello" as="hello" template="customer/account/dashboard/hello.phtml"/>
                <
block type="core/template" name="customer_account_dashboard_top" as="top" />
                <
block type="customer/account_dashboard_info" name="customer_account_dashboard_info" as="info" template="customer/account/dashboard/info.phtml"/>
                <
block type="customer/account_dashboard_newsletter" name="customer_account_dashboard_newsletter" as="newsletter" template="customer/account/dashboard/newsletter.phtml"/>
                <
block type="customer/account_dashboard_address" name="customer_account_dashboard_address" as="address" template="customer/account/dashboard/address.phtml"/>
                <
block type="core/template" name="customer_account_dashboard_info1" as="info1" />
                <
block type="core/template" name="customer_account_dashboard_info2" as="info2" />
            </
block>
        </
reference>
        
    </
mymodule_profile_index>

this is basically copied from from customer_account_index

I cannot get it to render. I just want to let it render the same page as the My Account Page. If I comment out the line that’s causing fatal error, it would render the magento front page. Can someone help me or guide me through this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
cooldar
Sr. Member
 
Total Posts:  95
Joined:  2008-05-14
 

I’ve dug deeper into the problem by outputing some messages and I noticed that Magento is not finding the block because it was looking into the path of my module

filepath = ./Pretty/Mymodule/Block/Profile.php

filepath = /usr/lib/php/Pretty/Mymodule/Block/Profile.php

filepath = /usr/local/lib/php/Pretty/Mymodule/Block/Profile.php

file = false

How do I specify the path????? I don’t see such option in config.xml

 
Magento Community Magento Community
Magento Community
Magento Community
 
cooldar
Sr. Member
 
Total Posts:  95
Joined:  2008-05-14
 

nevermind my file was lower case

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top