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

Understanding the programming of magento
 
number25
Member
 
Total Posts:  64
Joined:  2008-07-12
 

I notice that within every template of magento. almost 99% of all the code has a ($this->) in it to call methods. This makes me to believe that some how some way every template is included within some sort of class. My question is how do they have it structured to do that ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

All the classes are extended off of a few main ones using inheritance.  If you are referring to the templates, that is controlled by the Block code and the variables that are available to the templates are via the assign() function in the Block code.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
Unirgy
Guru
 
Avatar
Total Posts:  478
Joined:  2007-09-07
 

the template’s <?php echo $this->getSomeCustomVariable() ?> is available by setting it from the php block or outside by $this->setSomeCustomVariable(’some value’);

 
Magento Community Magento Community
Magento Community
Magento Community
 
nicolas46
Sr. Member
 
Total Posts:  210
Joined:  2008-04-09
Toulouse
 

You have to look the Zend Framwork to understand how that work.

For exemple $this in app/desing/frontend/default/default/template/catalog/product/view.phtml is an object of the class view.php of app/code/core/Mage/Catalog/Block/Product/View.php

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