magento #1 - mvc - template - workflow vida. mvc mage_model mage_model_resource mage_model...
TRANSCRIPT
MVC
M
VC
• Mage_Model• Mage_Model_Resour
ce
• Mage_Controller_Front• Mage_Events
• Mage_Block• Mage_Helper
Class naming conversionZend-styleFormat
◦Mage_Catalog_Model◦<Namespace>_<Module-
name>_Model_Notes:
◦Case sensitive◦Camelcase
Likipe_Demo_Model_CustomerService
◦Subfolder for each “dash”
ControllerRouting
◦Front controller◦URL Rewrite◦HTACCESS
Verify routingMage::app()->getFrontController()->getRequest()->getRouteName()
ModelE.A.V (Entity–Attribute–Value)Use
◦Mage::getModel()◦Mage::getSingleton()
Resources◦DB layer to work with MySQL◦= table in MySQL
Block - Types• Mage_Catalog_Block_Category_Navigati
on• Mage_Catalog_Block_Product• …
#1. “Built-in”
• Mage_Core_Block_Template• XXX_YYY_Block_ZZZ
#2: “Dynamic
data”
• Mage_CMS_Block#3: “Static
data”
Block – How to call• echo $this->getLayout()
->createBlock('letter/subscribe')->setTemplate('newsletter/subscribe.phtml')->toHtml();
.phtml
• <block type="cms/block" name="cms_site_info“ before="-" as="my_site_info“ />
• $this->getChildHtml(‘cms_site_info’)
.xml• {{block type="tag/popular"
name="tags_popular" template="tag/popular_index.phtml" }}
cms
Template - themeLayouts : XML files, define block
structure(module layout) , in which you decide to put some box in some page as a module function.
Templates : phtml files, in which you do the coding with xhtml and PHP.
Locale: language translations in .csv file format.
Skins : css, images, javascript, where u do the beautifications.
Workflow – Theme development
Page• page/1column.phtml• page/2-column-left.phtml• …
Header/Footer
• page/html/head.phtml• page/html/header.phtml• page/html/footer.phtml
Content• *.pht
ml
Workflow – Theme development
Use local.xml◦Remove/add blocks◦Change template file
Copy xml files:◦Layout change (modify on many blocks)
Copy phtml files◦Keep the PHP codes (correct data)◦HTML changes only
Translate via /locale/sv_SE/translate.csv