Try the Demo

Magento Forum

   
Name convention confuse
 
nostrzak
Jr. Member
 
Avatar
Total Posts:  22
Joined:  2007-09-18
Wroclaw, Poland
 

Hey,

I think that in templates $this->getHelper() and $this->helper() are very confusing. $this->getHelper() should be sth like $this->getBlock() since this one receives block instance. Maybe I’m missing something here? smile

 Signature 

http://nostrzak.blogspot.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

it thought it did follow the usual naming convention.....for instance:

<a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend'?></a><br />

//shouldn't the getHelper variety be like this?:
Mage::getHelper('catalog/product')->doSomething();

 Signature 

@ My Magento Blog

- Handy tutorials on programming and designing Magento. A continual work in progress!
- Now with a new design, new hosting and a new domain! Check it out!

 
Magento Community Magento Community
Magento Community
Magento Community
 
nostrzak
Jr. Member
 
Avatar
Total Posts:  22
Joined:  2007-09-18
Wroclaw, Poland
 

Maybe I wasn’t clear enough. When you do such experiment:

echo(get_class($this->helper('checkout/cart')));
echo(
get_class($this->getHelper('checkout/cart')));

you’ll get such output:

Mage_Checkout_Helper_Cart
Mage_Checkout_Block_Cart

First one is helper instance, second one is block. The second function name is misleading since it’s talking about helpers, not blocks. It’s no problem since you know it, but took me some minutes to notice it smile

 Signature 

http://nostrzak.blogspot.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 
nostrzak - 20 August 2008 10:11 PM

Maybe I wasn’t clear enough. When you do such experiment:

echo(get_class($this->helper('checkout/cart')));
echo(
get_class($this->getHelper('checkout/cart')));

you’ll get such output:

Mage_Checkout_Helper_Cart
Mage_Checkout_Block_Cart

First one is helper instance, second one is block. The second function name is misleading since it’s talking about helpers, not blocks. It’s no problem since you know it, but took me some minutes to notice it smile

that’s weird -

Possibly a bug? - perhaps the “getHelper” is being read using the magic __call function and isn’t recognized properly?

 Signature 

@ My Magento Blog

- Handy tutorials on programming and designing Magento. A continual work in progress!
- Now with a new design, new hosting and a new domain! Check it out!

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